active_admin_sidebar 0.1.0.rc2 → 0.1.0.rc3

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: e2eb11d92b77af4aca4716dddeaf08996f87c665
4
- data.tar.gz: efd17b7a1af59e3f14b6ea8c57d2db73ff83621e
3
+ metadata.gz: f5c5c51fa6d1bbcd8febffeb2249ae313ff93eea
4
+ data.tar.gz: 1c3c5cfe4e565da150e8cddb6ca2703f6249142d
5
5
  SHA512:
6
- metadata.gz: 820287549c26c0f713b341b49cb85447467f2219b96853716ad2c03da61ad16ae4e6171b750d7968ceb7fe3ac58c331757ce0dfd042367626872d05144ef2eae
7
- data.tar.gz: f8ff94e5be2dbafc8785191bbd7fe2da864999e80150d58924768c67f85ca795819daa5a56a701a7260534649f83ae1887ccd2e01609e055b8ea980b58bf30ce
6
+ metadata.gz: 8d3b5c8f5720733dc53cd7e5f79e1564c2027d6f5437a2f06a99ec840ed432299484dab06c71863482c1e7366dd6655088a645ed6d188f9c9546a3f09f1f7419
7
+ data.tar.gz: 1c25cff3122cdd24d2837f56abd060e4aa9d78c60775aef5ae38b470b4bab6df50cc2895a6cb2eb04dd3cd21b5cb27be2bdf5f22bffd5dde814b10bc5d711f00
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # ActiveAdminSidebar
2
+
3
+ Provides ability to manipulate sidebar position with activeadmin (tested with activeadmin ~> 1.0.0.pre)
4
+
5
+
6
+ Add including of css file
7
+
8
+ ```scss
9
+ @import "active_admin_sidebar";
10
+ ```
11
+
12
+ to the
13
+ ```
14
+ app/assets/stylesheets/active_admin.css.scss
15
+ ```
16
+
17
+ And including of coffee file (optional, need only for collapsed sidebar)
18
+
19
+ ```js
20
+ //= require active_admin_sidebar
21
+ ```
22
+
23
+ to the
24
+ ```
25
+ app/assets/javascripts/active_admin.js
26
+ ```
27
+
28
+ Changing sidebar position dynamically with before_filter
29
+ ```ruby
30
+ # app/admin/posts.rb
31
+ ActiveAdmin.register Post do
32
+ before_filter :left_sidebar!, only: [:show]
33
+ end
34
+
35
+ # app/admin/comments.rb
36
+ ActiveAdmin.register Comment do
37
+ before_filter :right_sidebar!
38
+ end
39
+ ```
40
+
41
+
42
+ Moving sidebar to the left within all resource (config/initializers/active_admin.rb)
43
+
44
+ ```ruby
45
+ # == Controller Filters
46
+ #
47
+ # You can add before, after and around filters to all of your
48
+ # Active Admin resources from here.
49
+ #
50
+ config.before_filter do
51
+ left_sidebar! if respond_to?(:left_sidebar!)
52
+ end
53
+ ```
54
+
55
+ Also you can use sidebar collapsing. It will add css icon in title of first sidebar will save current state in session
56
+ ```ruby
57
+ left_sidebar!(collapsed: true)
58
+ ```
59
+ You can override button color according to your color theme:
60
+ ```css
61
+ body.active_admin {
62
+ #active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
63
+ .collapse_btn, .uncollapse_btn {
64
+ background-color: #767270;
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ Example
71
+
72
+ http://oi45.tinypic.com/1zx1a3r.png
73
+
74
+
75
+
76
+
@@ -0,0 +1,23 @@
1
+ $(document).ready ->
2
+ if $('body').hasClass('index') && ($('#active_admin_content').hasClass('collapsible_sidebar'))
3
+
4
+ $aa_content = $('#active_admin_content')
5
+
6
+ $aa_content.find('.sidebar_section:first>h3').append(
7
+ '<span class="collapse_btn icono-caret-left" title="Hide sidebar"></span>')
8
+
9
+ $aa_content.prepend(
10
+ '<span class="uncollapse_btn icono-caret-right" title="Show sidebar"></span>')
11
+
12
+ set_collapsed_sidebar = (value) ->
13
+ $.getJSON(this.href, {collapsed_sidebar: value})
14
+
15
+ $aa_content.on 'click', '.collapse_btn, .uncollapse_btn', (e) ->
16
+ if !$aa_content.hasClass('collapsed_sidebar')
17
+ set_collapsed_sidebar(true)
18
+ $aa_content.removeClass('left_sidebar')
19
+ $aa_content.addClass('collapsed_sidebar')
20
+ else
21
+ set_collapsed_sidebar(false)
22
+ $aa_content.removeClass('collapsed_sidebar')
23
+ $aa_content.addClass('left_sidebar')
@@ -0,0 +1,87 @@
1
+ @import "active_admin_sidebar_pure_icons";
2
+
3
+ body.active_admin {
4
+ #active_admin_content.left_sidebar, #active_admin_content.collapsed_sidebar {
5
+ #sidebar {
6
+ display: block;
7
+ margin-left: 0;
8
+ }
9
+
10
+ .paginated_collection_contents {
11
+ clear: none;
12
+ float: left;
13
+ width: 100%;
14
+ }
15
+
16
+ .blank_slate_container {
17
+ clear: none;
18
+ }
19
+
20
+ .columns {
21
+ clear: none;
22
+ }
23
+
24
+ #main_content_wrapper {
25
+ float: inherit;
26
+ margin-left: 298px;
27
+ width: auto;
28
+ #main_content {
29
+ float: inherit;
30
+ margin: 0;
31
+ .tabs .comments {
32
+ .active_admin_comment {
33
+ clear: none;
34
+ }
35
+ }
36
+ }
37
+
38
+ }
39
+
40
+ .table_tools:after {
41
+ clear: none;
42
+ padding-bottom: 16px;
43
+ }
44
+
45
+ .collapse_btn, .uncollapse_btn {
46
+ background-color: #767270;
47
+ border-radius: 5px;
48
+ color: #ffffff;
49
+ cursor: pointer;
50
+ }
51
+
52
+ .collapse_btn {
53
+ clear: both;
54
+ display: block;
55
+ float: right;
56
+ }
57
+
58
+ .uncollapse_btn {
59
+ display: none;
60
+ margin-top: 5px;
61
+ position: absolute;
62
+ }
63
+
64
+ }
65
+ }
66
+
67
+ body.active_admin #active_admin_content.collapsed_sidebar {
68
+
69
+ #main_content_wrapper {
70
+ margin-left: 30px;
71
+ }
72
+
73
+ #sidebar {
74
+ display: none;
75
+ }
76
+
77
+ .uncollapse_btn {
78
+ display: block;
79
+ }
80
+
81
+ }
82
+
83
+ body.active_admin.index #active_admin_content.with_sidebar.collapsible_sidebar {
84
+ #main_content_wrapper #main_content {
85
+ margin-right: 0;
86
+ }
87
+ }
@@ -0,0 +1,66 @@
1
+ /* .icono-caret-left */
2
+ .icono-caret-right, .icono-caret-left {
3
+ height: 19px;
4
+ width: 19px;
5
+ }
6
+
7
+ .icono-caret-right:before,
8
+ .icono-caret-right:after,
9
+ .icono-caret-left:before,
10
+ .icono-caret-left:after {
11
+ bottom: 1px;
12
+ box-shadow: inset 0 0 0 32px;
13
+ height: 2px;
14
+ margin: auto 0;
15
+ position: absolute;
16
+ right: 6px;
17
+ transform-origin: right;
18
+ width: 8px;
19
+ }
20
+
21
+ .icono-caret-right:before, .icono-caret-left:before {
22
+ top: 2px;
23
+ -moz-transform: rotate(45deg);
24
+ -ms-transform: rotate(45deg);
25
+ -o-transform: rotate(45deg);
26
+ -webkit-transform: rotate(45deg);
27
+ transform: rotate(45deg);
28
+ }
29
+
30
+ .icono-caret-right:after, .icono-caret-left:after {
31
+ top: 0;
32
+ -moz-transform: rotate(-45deg);
33
+ -ms-transform: rotate(-45deg);
34
+ -o-transform: rotate(-45deg);
35
+ -webkit-transform: rotate(-45deg);
36
+ transform: rotate(-45deg);
37
+ }
38
+
39
+ .icono-caret-left {
40
+ -moz-transform: rotate(180deg);
41
+ -ms-transform: rotate(180deg);
42
+ -o-transform: rotate(180deg);
43
+ -webkit-transform: rotate(180deg);
44
+ transform: rotate(180deg);
45
+ }
46
+
47
+ [class*="icono-"] {
48
+ direction: ltr;
49
+ display: inline-block;
50
+ font-style: normal;
51
+ position: relative;
52
+ text-align: left;
53
+ text-indent: -9999px;
54
+ vertical-align: middle;
55
+ }
56
+
57
+ [class*="icono-"]:before,
58
+ [class*="icono-"]:after {
59
+ content: "";
60
+ pointer-events: none;
61
+ }
62
+
63
+ [class*="icono-"],
64
+ [class*="icono-"] * {
65
+ box-sizing: border-box;
66
+ }
@@ -1,7 +1,7 @@
1
- require 'active_admin'
1
+ require "active_admin"
2
2
  require "active_admin_sidebar/version"
3
- require 'active_admin_sidebar/activeadmin_views_pages_base'
4
- require 'active_admin_sidebar/positions'
3
+ require "active_admin_sidebar/activeadmin_views_pages_base"
4
+ require "active_admin_sidebar/positions"
5
5
 
6
6
  module ActiveAdminSidebar
7
7
  module Rails
@@ -12,6 +12,3 @@ module ActiveAdminSidebar
12
12
  end
13
13
  end
14
14
  end
15
-
16
-
17
-
@@ -2,35 +2,42 @@ class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
2
2
 
3
3
  def build_page_content
4
4
  build_flash_messages
5
- classes = Arbre::HTML::ClassList.new
6
-
7
- if skip_sidebar?
8
- classes << 'without_sidebar'
9
- else
10
- classes << 'with_sidebar'
11
- classes << 'left_sidebar' if left_sidebar?
12
- end
13
-
14
-
15
-
16
- div :id => "active_admin_content", :class => classes do
17
-
5
+ div id: "active_admin_content", class: main_content_classes do
18
6
  build_sidebar unless skip_sidebar? || right_sidebar?
19
7
  build_main_content_wrapper
20
8
  build_sidebar unless skip_sidebar? || left_sidebar?
21
-
22
9
  end
23
10
  end
24
11
 
25
-
26
12
  def left_sidebar?
27
- assigns[:sidebar_position] == :left
13
+ assigns[:sidebar_options].try!(:[], :position) == :left
14
+ end
15
+
16
+ def collapsible_sidebar?
17
+ left_sidebar? && !!assigns[:sidebar_options].try!(:[], :collapsed)
18
+ end
19
+
20
+ def sidebar_is_collapsed?
21
+ !!assigns[:sidebar_options].try!(:[], :is_collapsed)
28
22
  end
29
23
 
30
24
  def right_sidebar?
31
25
  !left_sidebar?
32
26
  end
33
27
 
28
+ def main_content_classes
29
+ classes = Arbre::HTML::ClassList.new
30
+ if skip_sidebar?
31
+ classes << "without_sidebar"
32
+ else
33
+ classes << "with_sidebar"
34
+ classes << "left_sidebar" if left_sidebar?
35
+ if collapsible_sidebar?
36
+ classes << "collapsible_sidebar"
37
+ classes << "collapsed_sidebar" if sidebar_is_collapsed?
38
+ end
39
+ end
40
+ classes
41
+ end
34
42
 
35
-
36
- end
43
+ end
@@ -1,10 +1,28 @@
1
1
  module ActiveAdminSidebar
2
2
  module Positions
3
- def left_sidebar!
4
- @sidebar_position = :left
3
+ def left_sidebar!(options = {})
4
+ @sidebar_options = { position: :left }
5
+ if options.fetch(:collapsed, false)
6
+ collapsed_sidebar
7
+ @sidebar_options.merge!(
8
+ is_collapsed: session[:collapsed_sidebar],
9
+ collapsed: true
10
+ )
11
+ end
5
12
  end
13
+
6
14
  def right_sidebar!
7
- @sidebar_position = :right
15
+ @sidebar_options = { position: :right }
16
+ end
17
+
18
+ def collapsed_sidebar
19
+ if request.xhr?
20
+ if params[:collapsed_sidebar].present?
21
+ collapsed = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include? params[:collapsed_sidebar]
22
+ session[:collapsed_sidebar] = collapsed
23
+ render json: { collapsed_sidebar: collapsed } and return
24
+ end
25
+ end
8
26
  end
9
27
 
10
28
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminSidebar
2
- VERSION = "0.1.0.rc2"
2
+ VERSION = "0.1.0.rc3"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_sidebar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc2
4
+ version: 0.1.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -33,14 +33,17 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - Gemfile
35
35
  - LICENSE
36
- - README.rdoc
36
+ - README.md
37
37
  - Rakefile
38
38
  - active_admin_sidebar.gemspec
39
- - app/assets/stylesheets/active_admin_sidebar.css.scss
39
+ - app/assets/javascripts/active_admin_sidebar.coffee
40
+ - app/assets/stylesheets/active_admin_sidebar.scss
41
+ - app/assets/stylesheets/active_admin_sidebar_pure_icons.scss
40
42
  - lib/active_admin_sidebar.rb
41
43
  - lib/active_admin_sidebar/activeadmin_views_pages_base.rb
42
44
  - lib/active_admin_sidebar/positions.rb
43
45
  - lib/active_admin_sidebar/version.rb
46
+ - screen/sidebar.jpg
44
47
  homepage: https://github.com/Fivell/active_admin_sidebar
45
48
  licenses: []
46
49
  metadata: {}
@@ -60,8 +63,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  version: 1.3.1
61
64
  requirements: []
62
65
  rubyforge_project:
63
- rubygems_version: 2.2.2
66
+ rubygems_version: 2.5.0
64
67
  signing_key:
65
68
  specification_version: 4
66
69
  summary: active_admin_sidebar gem
67
70
  test_files: []
71
+ has_rdoc:
data/README.rdoc DELETED
@@ -1,53 +0,0 @@
1
- active_admin_sidebar
2
- ====================
3
-
4
- easy change sidebar position with activeadmin (tested with activeadmin ~> 1.0.0.pre)
5
-
6
-
7
- Add including of css file
8
-
9
- @import "active_admin_sidebar";
10
-
11
- to the app/assets/stylesheets/active_admin.css.scss
12
-
13
-
14
- Changing sidebar position dynamically with before_filter
15
-
16
- # app/admin/posts.rb
17
- ActiveAdmin.register Post do
18
- before_filter :left_sidebar!, only: [:show]
19
- end
20
-
21
- # app/admin/comments.rb
22
- ActiveAdmin.register Comment do
23
- before_filter :right_sidebar!
24
- end
25
-
26
-
27
-
28
- Moving sidebar to the left within all resource (config/initializers/active_admin.rb)
29
-
30
-
31
- # == Controller Filters
32
- #
33
- # You can add before, after and around filters to all of your
34
- # Active Admin resources from here.
35
- #
36
- config.before_filter do
37
- left_sidebar!
38
- end
39
-
40
- Disabling using sidebar layout on dashboards (if you setup sidebar position with initializer)
41
-
42
- ActiveAdmin.register_page "Dashboard" do
43
- controller {skip_before_filter :left_sidebar!}
44
- #.....
45
- end
46
-
47
- Example
48
-
49
- http://oi45.tinypic.com/1zx1a3r.png
50
-
51
-
52
-
53
-
@@ -1,42 +0,0 @@
1
- body.active_admin #active_admin_content.left_sidebar {
2
-
3
- #sidebar{
4
- margin-left:0;
5
- }
6
-
7
- .paginated_collection_contents{
8
- clear: none;
9
- float: left;
10
- width: 100%;
11
- }
12
-
13
- .blank_slate_container{
14
- clear:none;
15
- }
16
-
17
- .columns {
18
- clear: none;
19
- }
20
-
21
- #main_content_wrapper{
22
- float:inherit;
23
- width:auto;
24
- margin-left: 298px;
25
- #main_content{
26
- margin:0;
27
- float: inherit;
28
- .tabs .comments {
29
- .active_admin_comment {
30
- clear: none;
31
- }
32
- }
33
- }
34
-
35
- }
36
-
37
- .table_tools:after {
38
- clear: none;
39
- padding-bottom: 16px;
40
- }
41
- }
42
-