simple_sidebar 0.0.1.pre

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
+ SHA256:
3
+ metadata.gz: 8fad6bb78024f4558c3143f3f0c1f7b10fb9fdbd1a01ae95ab04ce9dd62e3319
4
+ data.tar.gz: e50593f52f64be048658dae81689eb3aad693d4168faf35fe81ea26ce13b9f24
5
+ SHA512:
6
+ metadata.gz: ff9a4d0b9cdb66cf743837a76685d0ef8dc412b1f706aab2b0090e95c63f878938f86488771569671ab1515fecdae4730154863c368f795ed9a9aa381237e73b
7
+ data.tar.gz: d9186df087cbcfc44d9164c41b66dcef4d90aede982128895ca1d7fe0dc177bde3af34e5c69ae603f39fe0c364e7e9fdabe901952656f9488604520b82e9d12d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Roberto Vasquez Angel
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/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "Simple Sidebar"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.rdoc")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,104 @@
1
+ # Usage:
2
+ #
3
+ # Put all the content that is not in the sidebar in a container with the id #main-content a trigger button and add a sidebar.
4
+ #
5
+ # <body>
6
+ # <div id="main-content">
7
+ # <button data-sidebar-trigger="#example-sidebar">
8
+ # Toggle the example sidebar!
9
+ # </button>
10
+ # </div>
11
+ # <aside
12
+ # id="example-sidebar">
13
+ # data-sidebar-load="/de/backend/authentifizierung/user_sidebar.html"
14
+ # data-sidebar-mode="overlay"
15
+ # data-sidebar-position="right"
16
+ # data-sidebar-size="20rem"
17
+ # data-sidebar-state="closed"
18
+ # <h3>Hello from the example sidebar!</h3>
19
+ # </aside>
20
+ # </body>
21
+ #
22
+ # Options:
23
+ #
24
+ # load: Passing an url to load will load the content of the url via ajax and display it in the sidebar.
25
+ # mode:
26
+ # push: This will decrease the size of the main content, making room for the sidebar.
27
+ # overlay: This will show the sidebar on top of the content, without moving it.
28
+ # modal: Like overlay, but with a modal background.
29
+ # position: left|right|top|bottom
30
+ # size: size that the sidebar will take up (width for left and right, height for top and bottom). Pass any css size in px, rem or whatever you like.
31
+ #
32
+ $ ->
33
+ $('body').on 'click', '#sidebar-modal-background', ->
34
+ target = $("##{$(@).data('sidebar-target')}")
35
+ closeModal(target)
36
+
37
+ $('[data-sidebar-position]').each (_, e) ->
38
+ position = $(@).data('sidebar-position')
39
+ $(e).addClass("sidebar sidebar-#{position}")
40
+ if $(@).data('sidebar-state') == 'opened'
41
+ openModal($(@))
42
+
43
+ $('[data-sidebar-trigger]').on 'click', ->
44
+ target = $($(@).data('sidebar-trigger'))
45
+ state = target.data('sidebar-state')
46
+
47
+ if state == 'closed'
48
+ openModal(target)
49
+ else
50
+ closeModal(target)
51
+
52
+ openModal = (target) ->
53
+ main_content = $('#main-content')
54
+
55
+ position = target.data('sidebar-position')
56
+ mode = target.data('sidebar-mode')
57
+ size_attribute = if position in ['top', 'bottom'] then 'height' else 'width'
58
+ size = target.data('sidebar-size')
59
+
60
+ target.css("display", "inherit")
61
+ target.css(size_attribute, size)
62
+ main_content.css("margin-#{position}", size) if mode == 'push'
63
+
64
+
65
+ # modal
66
+ if mode == 'modal'
67
+ $("body").append("<div id=\"sidebar-modal-background\" data-sidebar-target=\"#{target.attr('id')}\"></div>")
68
+
69
+ # load
70
+ if target.data('sidebar-load')
71
+ url = target.data('sidebar-load')
72
+ $.ajax
73
+ type: 'GET'
74
+ url: url
75
+ success: (response) ->
76
+ $(target).html(response)
77
+ return
78
+
79
+ # set state
80
+ target.data('sidebar-state', 'opened')
81
+
82
+ closeModal = (target) ->
83
+ main_content = $('#main-content')
84
+
85
+ position = target.data('sidebar-position')
86
+ mode = target.data('sidebar-mode')
87
+ size_attribute = if position in ['top', 'bottom'] then 'height' else 'width'
88
+ size = target.data('sidebar-size')
89
+
90
+ # push
91
+ if mode == 'push'
92
+ main_content.css("margin-#{position}", size)
93
+
94
+ # modal
95
+ if mode == 'modal'
96
+ $("#sidebar-modal-background").remove()
97
+
98
+ target.css(size_attribute, '0px')
99
+
100
+ if mode == 'push'
101
+ main_content.css("margin-#{position}", '0px')
102
+
103
+ # set state
104
+ target.data('sidebar-state', 'closed')
@@ -0,0 +1 @@
1
+ //= require_tree ./application
@@ -0,0 +1 @@
1
+ //= require simple_sidebar/application
@@ -0,0 +1,51 @@
1
+ .sidebar {
2
+ position: fixed;
3
+ z-index: 3000;
4
+ overflow-x: hidden;
5
+ transition: 0.5s;
6
+ }
7
+
8
+ .sidebar-left {
9
+ height: 100%;
10
+ width: 0;
11
+ top: 0;
12
+ left: 0;
13
+ }
14
+ .sidebar-right {
15
+ height: 100%;
16
+ width: 0;
17
+ top: 0;
18
+ right: 0;
19
+ }
20
+ .sidebar-top {
21
+ width: 100%;
22
+ height: 0;
23
+ left: 0;
24
+ top: 0;
25
+ }
26
+ .sidebar-bottom {
27
+ width: 100%;
28
+ height: 0;
29
+ left: 0;
30
+ bottom: 0;
31
+ }
32
+
33
+ #sidebar-modal-background {
34
+ position: fixed;
35
+ z-index: 2000;
36
+ left: 0;
37
+ top: 0;
38
+ width: 100%;
39
+ height: 100%;
40
+ background-color: rgb(0,0,0);
41
+ background-color: rgba(0,0,0,0.4);
42
+ }
43
+
44
+ #main-content {
45
+ transition: margin .5s;
46
+ }
47
+
48
+ /* @media screen and (max-height: 450px) {
49
+ .sidebar {padding-top: 15px;}
50
+ .sidebar a {font-size: 18px;}
51
+ } */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require_tree ./application
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require simple_sidebar/application
3
+ */
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.assets.precompile += %w( simple_sidebar.css )
4
+ Rails.application.config.assets.precompile += %w( simple_sidebar.js )
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleSidebar
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace SimpleSidebar
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleSidebar
4
+ VERSION = "0.0.1.pre".freeze
5
+ end
@@ -0,0 +1,4 @@
1
+ require "simple_sidebar/engine"
2
+
3
+ module SimpleSidebar
4
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_sidebar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Vasquez Angel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - roberto@vasquez-angel.de
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - Rakefile
22
+ - app/assets/javascripts/simple_sidebar.js
23
+ - app/assets/javascripts/simple_sidebar/application.js
24
+ - app/assets/javascripts/simple_sidebar/application/core.js.coffee
25
+ - app/assets/stylesheets/simple_sidebar.css
26
+ - app/assets/stylesheets/simple_sidebar/application.css
27
+ - app/assets/stylesheets/simple_sidebar/application/core.css
28
+ - config/initializers/assets.rb
29
+ - lib/simple_sidebar.rb
30
+ - lib/simple_sidebar/engine.rb
31
+ - lib/simple_sidebar/version.rb
32
+ homepage:
33
+ licenses:
34
+ - MIT
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">"
48
+ - !ruby/object:Gem::Version
49
+ version: 1.3.1
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.7.7
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Simple sidebar.
56
+ test_files: []