simple_sidebar 0.0.2.pre → 0.0.6.pre

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6c8cfb26fe5f3067b7f90aa1877e35310286ec547953b8fe105b0347b872d53
4
- data.tar.gz: e7cf4ec723265a31cae6b8a0a70e12fb2958fd1bde1b599b881c6d44e45b7b63
3
+ metadata.gz: 12b49ad6da2f3a70f0ff42aae6693f2cb8c11068205d1c0d30feaf485a3ba06d
4
+ data.tar.gz: e565b066187ce8c22eff03e42a484aa15673d49965eec14fdf42bd0a6b6dd413
5
5
  SHA512:
6
- metadata.gz: 86a5a613c1c626c439e518f2e1c5b0b2aaa60e9e6ece42999b9f13b86dca8047eea533d48a6ac69fee2ae74b25631293f0a3df478fe9d1b014f3c6c41ca19790
7
- data.tar.gz: 3d7d44cec8e331f42cb22da8baf120d486860db960edb355de5f4c07fefc4a36a1ba9faa4750de4e20b7d5e44a65970ef4442a927d064bbd93ea90e612ce8f3e
6
+ metadata.gz: ac369c508ef423b47c6a7ffa1156ebafc173bbf5f89e307f126fca91ab31a951c09c4cb3aaffd66cd81e877482b0ea607712d90f0e33e4e164fae77e3362e53f
7
+ data.tar.gz: eab0e4f47c56a41c33c25e021a4476219264986ed153b9c57a0bfd123fae02b21b75cdcb574c84bce52aa7ff087015953619c08b5292d2078dd7131529059a8a
@@ -28,6 +28,7 @@
28
28
  # modal: Like overlay, but with a modal background.
29
29
  # position: left|right|top|bottom
30
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
+ # state: open|closed
31
32
  #
32
33
  $ ->
33
34
  initializeSidebars = ->
@@ -36,6 +37,8 @@ $ ->
36
37
  position = $(@).data('sidebar-position')
37
38
  mode = $(@).data('sidebar-mode')
38
39
  size = $(@).data('sidebar-size')
40
+ state = $(@).data('sidebar-state')
41
+
39
42
  $(e).addClass("sidebar sidebar-#{position} sidebar-#{mode}")
40
43
 
41
44
  # set correct size
@@ -51,14 +54,16 @@ $ ->
51
54
  # display it
52
55
  $(e).css("display", "inherit")
53
56
 
54
- initializeSidebars()
57
+ # set initial state
58
+ if state == 'open'
59
+ openSidebar($(@), false)
60
+
55
61
 
56
62
  initializeModalBackground = ->
57
63
  $('body').on 'click', '#sidebar-modal-background', ->
58
64
  target = $("##{$(@).data('sidebar-target')}")
59
65
  closeSidebar(target)
60
66
 
61
- initializeModalBackground()
62
67
 
63
68
  initializeTriggers = ->
64
69
  $('[data-sidebar-trigger]').on 'click', ->
@@ -66,13 +71,12 @@ $ ->
66
71
  state = target.data('sidebar-state')
67
72
 
68
73
  if state == 'closed'
69
- openSidebar(target)
74
+ openSidebar(target, true)
70
75
  else
71
- closeSidebar(target)
76
+ closeSidebar(target, true)
72
77
 
73
- initializeTriggers()
74
78
 
75
- openSidebar = (target) ->
79
+ openSidebar = (target, animate = false) ->
76
80
  main_content = $('#main-content')
77
81
 
78
82
  position = target.data('sidebar-position')
@@ -80,19 +84,25 @@ $ ->
80
84
  size = target.data('sidebar-size')
81
85
 
82
86
  # Move sidebar into viewport
83
- target.css(position, 0)
87
+ if(animate == true)
88
+ target.animate({ "#{position}": 0 }, 500);
89
+ else
90
+ target.css(position, 0)
84
91
 
85
92
  # Add margin equal to sidebar width/height to main content to make room
86
93
  # for the sidebar if in push mode
87
- main_content.css("margin-#{position}", size) if mode == 'push'
88
-
94
+ if(mode == 'push')
95
+ if(animate == true)
96
+ main_content.animate({ "margin-#{position}": size }, 500)
97
+ else
98
+ main_content.css("margin-#{position}", size)
89
99
 
90
100
  # add modal if in modal mode
91
101
  if mode == 'modal'
92
102
  $("body").append("<div id=\"sidebar-modal-background\" data-sidebar-target=\"#{target.attr('id')}\"></div>")
93
103
  $('#sidebar-modal-background').fadeIn()
94
104
 
95
- # load content via ajay if the load option was given
105
+ # load content via ajax if the load option was given
96
106
  if target.data('sidebar-load')
97
107
  url = target.data('sidebar-load')
98
108
  $.ajax
@@ -103,9 +113,9 @@ $ ->
103
113
  return
104
114
 
105
115
  # set state
106
- target.data('sidebar-state', 'opened')
116
+ target.data('sidebar-state', 'open')
107
117
 
108
- closeSidebar = (target) ->
118
+ closeSidebar = (target, animate = false) ->
109
119
  main_content = $('#main-content')
110
120
 
111
121
  position = target.data('sidebar-position')
@@ -115,14 +125,23 @@ $ ->
115
125
 
116
126
  # push
117
127
  if mode == 'push'
118
- # main_content.css("margin-#{position}", size)
119
- main_content.css("margin-#{position}", '0px')
128
+ if(animate == true)
129
+ main_content.animate({ 'marginLeft': 0 }, 500);
130
+ else
131
+ main_content.css("margin-#{position}", '0px')
120
132
 
121
133
  # modal
122
134
  if mode == 'modal'
123
135
  $("#sidebar-modal-background").remove()
124
136
 
125
- target.css(position, "-#{target.outerWidth()}px")
137
+ if(animate == true)
138
+ target.animate({ "#{position}": "-#{target.outerWidth()}px" }, 500);
139
+ else
140
+ target.css(position, "-#{target.outerWidth()}px")
126
141
 
127
142
  # set state
128
143
  target.data('sidebar-state', 'closed')
144
+
145
+ initializeSidebars()
146
+ initializeModalBackground()
147
+ initializeTriggers()
@@ -15,27 +15,23 @@
15
15
  .sidebar-left {
16
16
  height: 100%;
17
17
  top: 0;
18
- transition: left .5s;
18
+ overflow-y: auto;
19
19
  }
20
20
  .sidebar-right {
21
21
  height: 100%;
22
22
  top: 0;
23
- transition: right .5s;
23
+ overflow-y: auto;
24
24
  }
25
25
  .sidebar-top {
26
26
  width: 100%;
27
27
  left: 0;
28
- transition: top .5s;
29
28
  }
30
29
  .sidebar-bottom {
31
30
  width: 100%;
32
31
  left: 0;
33
- transition: bottom .5s;
34
32
  }
35
33
 
36
- #main-content {
37
- transition: margin .5s;
38
- }
34
+ #main-content {}
39
35
 
40
36
  #sidebar-modal-background {
41
37
  display: none;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleSidebar
4
- VERSION = "0.0.2.pre".freeze
4
+ VERSION = "0.0.6.pre".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_sidebar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.pre
4
+ version: 0.0.6.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -142,15 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 2.5.0
145
+ version: 2.4.0
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">"
149
149
  - !ruby/object:Gem::Version
150
150
  version: 1.3.1
151
151
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.7.6
152
+ rubygems_version: 3.0.8
154
153
  signing_key:
155
154
  specification_version: 4
156
155
  summary: Simple sidebar.