gui_foldable_content 0.0.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d969a29117e6289847292d7de4de764d0c3041f
4
+ data.tar.gz: 5c9758d210d10fe7bc623478f09e36bf27cae16d
5
+ SHA512:
6
+ metadata.gz: 1f27539789819fa7cba273cd7e6f2d7247a43982b467baca0fa7e3b677699e6543e62e3772a0bd139b584463eb9fcfa10d1980ace44cd327a8c251eb51a85271
7
+ data.tar.gz: 2808e0c6cb2e2fe32e0bd30454a4950461c659ddf5bf6ab6e13c613177008d104741ae47d2d67ac6e457a9e8d7de3a9f4226e4c81a9f81b9cd8d4ba667981c96
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Leo Benkel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,45 @@
1
+ = AsyncDataFetch
2
+
3
+ This project uses MIT-LICENSE.
4
+
5
+ ---
6
+
7
+ == To use:
8
+
9
+ === In your gemfile
10
+
11
+ gem 'gui_foldable_content'
12
+
13
+ ---
14
+
15
+ === In application.js
16
+
17
+ //= require gui_foldable_content
18
+
19
+ ---
20
+
21
+ === In config/initializers/gui_foldable_content.rb
22
+
23
+ | GuiFoldableContent.configure do |config|
24
+ | config.default_close_indicator = 'UP'
25
+ | config.default_open_indicator = 'DOWN'
26
+ | end
27
+
28
+ So you can configure the default indicator across your application.
29
+ - *default_close_indicator* is the indicator on the side of the title when the block is closed. Default: '[C]'.
30
+ - *default_open_indicator* is the indicator on the side of the title when the block is open. Default: '[O]'.
31
+
32
+ ---
33
+
34
+ === In your views, user the helper:
35
+
36
+ <%= create_foldable_area(title: 'TITLE', title_tag: 'h3', default_state: false, close_indicator: simple_format('plop', {}, wrapper_tag: 'span' ), open_indicator: 'down' ) do %>
37
+ [SOME HTML CONTENT]
38
+ <% end %>
39
+
40
+ - *title* is the clickable table of the block.
41
+ - *title_tag* is the tag surrounding the title. Default: 'h3'.
42
+ - *default_state* is state of the block when the page load. Default: false (means closed)
43
+ - *close_indicator* is the indicator on the side of the title when the block is closed. Default: '[C]'.
44
+ - *open_indicator* is the indicator on the side of the title when the block is open. Default: '[O]'.
45
+
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GuiFoldableContent'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,58 @@
1
+
2
+
3
+ $(document).ready(function(){
4
+ $('.gui_foldable_area').each(function(i, elem){
5
+ var default_state = $(elem).data().default_foldable_state
6
+ $(elem).find('.gui_foldable_area_title').each(function(i, elem){
7
+ if (default_state) {
8
+ $(elem).find('.gui_foldable_indicator_open').show();
9
+ $(elem).find('.gui_foldable_indicator_close').hide();
10
+ } else {
11
+ $(elem).find('.gui_foldable_indicator_close').show();
12
+ $(elem).find('.gui_foldable_indicator_open').hide();
13
+ }
14
+ });
15
+ $(elem).find('.gui_foldable_content').each(function(i, elem){
16
+ $(elem).toggle(default_state);
17
+ $(elem).data().foldable_state = default_state
18
+ });
19
+ });
20
+ })
21
+
22
+ toggle_gui_divs = function(div_hidding, div_showing){
23
+ var hidden_opacity = 0.3;
24
+ var fading_speed = 'fast';
25
+
26
+ $(div_hidding).stop(true,true);
27
+ $(div_showing).stop(true,true);
28
+
29
+ $(div_hidding).fadeTo(fading_speed, hidden_opacity,'linear', function(){
30
+ $(div_showing).css('opacity', hidden_opacity);
31
+ $(div_hidding).hide();
32
+ $(div_showing).show();
33
+ $(div_showing).fadeTo(fading_speed, 1);
34
+ });
35
+ }
36
+
37
+ toggle_gui_foldable_content = function(title){
38
+
39
+ var foldy = $(title).next('.gui_foldable_content');
40
+ var state = foldy.data().foldable_state;
41
+
42
+ var fading_options = {
43
+ duration: 'fast',
44
+ queue: false,
45
+ easing: 'linear'
46
+ };
47
+
48
+ if (state) {
49
+ $(foldy).fadeOut(fading_options);
50
+
51
+ toggle_gui_divs($(title).find('.gui_foldable_indicator_open'), $(title).find('.gui_foldable_indicator_close'));
52
+ } else {
53
+ $(foldy).fadeIn(fading_options);
54
+ toggle_gui_divs($(title).find('.gui_foldable_indicator_close'), $(title).find('.gui_foldable_indicator_open'));
55
+ }
56
+
57
+ foldy.data().foldable_state = !state;
58
+ }
@@ -0,0 +1,3 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require ./folder_engine
@@ -0,0 +1,6 @@
1
+ <div class="gui_foldable_area" data-default_foldable_state="<%= _default_state %>">
2
+ <<%= _title_tag %> class="gui_foldable_area_title" onclick="toggle_gui_foldable_content(this);" style="cursor:pointer;"><%= _title %>&nbsp;<span class="gui_foldable_indicator_open"><%= _open_indicator %></span><span class="gui_foldable_indicator_close" ><%= _close_indicator %></span></<%= _title_tag %>>
3
+ <div class="gui_foldable_content" data-foldable_state="<%= _default_state %>">
4
+ <%= _content %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,16 @@
1
+ require "gui_foldable_content/configuration"
2
+ require 'gui_foldable_content/view_helpers'
3
+
4
+ module GuiFoldableContent
5
+ require 'gui_foldable_content/engine'
6
+
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+ def self.configure
14
+ yield(configuration)
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module GuiFoldableContent
2
+ class Configuration
3
+ attr_accessor :default_close_indicator
4
+ attr_accessor :default_open_indicator
5
+
6
+ def initialize
7
+ @default_close_indicator = "[C]"
8
+ @default_open_indicator = "[O]"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module GuiFoldableContent
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace GuiFoldableContent
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module GuiFoldableContent
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,9 @@
1
+ module GuiFoldableContent
2
+ module ViewHelpers
3
+ def create_foldable_area(title: , title_tag: "h3", default_state: false, close_indicator: GuiFoldableContent.configuration.default_close_indicator, open_indicator: GuiFoldableContent.configuration.default_open_indicator )
4
+ render partial: 'gui_foldable_content/foldable_content', locals: { _title_tag: title_tag, _title: title, _default_state: default_state, _content: capture { yield }, _close_indicator: close_indicator , _open_indicator: open_indicator }
5
+ end
6
+ end
7
+ end
8
+
9
+ ActionView::Base.send :include, GuiFoldableContent::ViewHelpers
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gui_foldable_content
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Leo Benkel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ description: Helper to have foldable blocks of html
42
+ email:
43
+ - leo.benkel@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.rdoc
50
+ - Rakefile
51
+ - app/assets/javascripts/gui_foldable_content/folder_engine.js
52
+ - app/assets/javascripts/gui_foldable_content/index.js
53
+ - app/views/gui_foldable_content/_foldable_content.html.erb
54
+ - lib/gui_foldable_content.rb
55
+ - lib/gui_foldable_content/configuration.rb
56
+ - lib/gui_foldable_content/engine.rb
57
+ - lib/gui_foldable_content/version.rb
58
+ - lib/gui_foldable_content/view_helpers.rb
59
+ homepage: https://gitlab.com/wonay/gui_foldable_content
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.3.0
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.5.1
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Helper to have foldable blocks of html
83
+ test_files: []