leaflet-sidebar-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/leaflet-sidebar-rails-0.0.1.gem +0 -0
- data/leaflet-sidebar-rails.gemspec +20 -0
- data/lib/leaflet-sidebar-rails/version.rb +1 -1
- data/vendor/assets/javascripts/L.Control.Sidebar.js +162 -0
- data/vendor/assets/stylesheets/L.Control.Sidebar.css +169 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd82e73844a035141ca9a0821883cd76a579b21
|
4
|
+
data.tar.gz: 9012751021d56cec7a51e003addfb83be61f3b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d83ceb1449ca31664ed647a3826d873f8e0af49356eba90c8b8c2ee6bb7c3b66a347c973197d22d293d72ec89f5df6cb817cbb1c1a096b66ef3d864ba1e15a73
|
7
|
+
data.tar.gz: 1f18428f98bb3ac13d88618fc6a656a24d6f007149eb9b31595e96894c3a529ca6504797b236763a3aef0501f690ddb5ce7923f3ddea780a310001cc27e0a5b8
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.rbc
|
2
|
+
*.sassc
|
3
|
+
.sass-cache
|
4
|
+
capybara-*.html
|
5
|
+
.rspec
|
6
|
+
.rvmrc
|
7
|
+
/.bundle
|
8
|
+
/vendor/bundle
|
9
|
+
/log/*
|
10
|
+
/tmp/*
|
11
|
+
/db/*.sqlite3
|
12
|
+
/public/system/*
|
13
|
+
/coverage/
|
14
|
+
/spec/tmp/*
|
15
|
+
**.orig
|
16
|
+
rerun.txt
|
17
|
+
pickle-email-*.html
|
18
|
+
.project
|
19
|
+
config/initializers/secret_token.rb
|
20
|
+
.DS_Store
|
data/Gemfile
ADDED
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "leaflet-sidebar-rails/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "leaflet-sidebar-rails"
|
9
|
+
s.version = Leaflet::Sidebar::Rails::VERSION
|
10
|
+
s.authors = ["Jack Reed"]
|
11
|
+
s.email = ["phillipjreed@gmail.com"]
|
12
|
+
s.summary = "Rails plugin for Leaflet-Sidebar plugin"
|
13
|
+
s.description = "A responsive sidebar for leaflet maps"
|
14
|
+
s.homepage = 'https://github.com/mejackreed/leaflet-sidebar-rails'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
# s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE.txt", "LICENSE-leaflet-sidebar.txt", "Rakefile", "README.md"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
L.Control.Sidebar = L.Control.extend({
|
2
|
+
|
3
|
+
includes: L.Mixin.Events,
|
4
|
+
|
5
|
+
options: {
|
6
|
+
closeButton: true,
|
7
|
+
position: 'left',
|
8
|
+
autoPan: true,
|
9
|
+
},
|
10
|
+
|
11
|
+
initialize: function (placeholder, options) {
|
12
|
+
L.setOptions(this, options);
|
13
|
+
|
14
|
+
// Find content container
|
15
|
+
var content = this._contentContainer = L.DomUtil.get(placeholder);
|
16
|
+
|
17
|
+
// Remove the content container from its original parent
|
18
|
+
content.parentNode.removeChild(content);
|
19
|
+
|
20
|
+
var l = 'leaflet-';
|
21
|
+
|
22
|
+
// Create sidebar container
|
23
|
+
var container = this._container =
|
24
|
+
L.DomUtil.create('div', l + 'sidebar ' + this.options.position);
|
25
|
+
|
26
|
+
// Style and attach content container
|
27
|
+
L.DomUtil.addClass(content, l + 'control');
|
28
|
+
container.appendChild(content);
|
29
|
+
|
30
|
+
// Create close button and attach it if configured
|
31
|
+
if (this.options.closeButton) {
|
32
|
+
var close = this._closeButton =
|
33
|
+
L.DomUtil.create('a', 'close', container);
|
34
|
+
close.innerHTML = '×';
|
35
|
+
}
|
36
|
+
},
|
37
|
+
addTo: function (map) {
|
38
|
+
var container = this._container;
|
39
|
+
var content = this._contentContainer;
|
40
|
+
|
41
|
+
// Attach event to close button
|
42
|
+
if (this.options.closeButton) {
|
43
|
+
var close = this._closeButton;
|
44
|
+
|
45
|
+
L.DomEvent.on(close, 'click', this.hide, this);
|
46
|
+
}
|
47
|
+
|
48
|
+
// Attach sidebar container to controls container
|
49
|
+
var controlContainer = map._controlContainer;
|
50
|
+
controlContainer.insertBefore(container, controlContainer.firstChild);
|
51
|
+
|
52
|
+
this._map = map;
|
53
|
+
|
54
|
+
// Make sure we don't drag the map when we interact with the content
|
55
|
+
var stop = L.DomEvent.stopPropagation;
|
56
|
+
L.DomEvent
|
57
|
+
.on(content, 'click', stop)
|
58
|
+
.on(content, 'mousedown', stop)
|
59
|
+
.on(content, 'touchstart', stop)
|
60
|
+
.on(content, 'dblclick', stop)
|
61
|
+
.on(content, 'mousewheel', stop)
|
62
|
+
.on(content, 'MozMousePixelScroll', stop);
|
63
|
+
|
64
|
+
return this;
|
65
|
+
},
|
66
|
+
|
67
|
+
removeFrom: function (map) {
|
68
|
+
//if the control is visible, hide it before removing it.
|
69
|
+
this.hide();
|
70
|
+
|
71
|
+
var content = this._contentContainer;
|
72
|
+
|
73
|
+
// Remove sidebar container from controls container
|
74
|
+
var controlContainer = map._controlContainer;
|
75
|
+
controlContainer.removeChild(this._container);
|
76
|
+
|
77
|
+
//disassociate the map object
|
78
|
+
this._map = null;
|
79
|
+
|
80
|
+
// Unregister events to prevent memory leak
|
81
|
+
var stop = L.DomEvent.stopPropagation;
|
82
|
+
L.DomEvent
|
83
|
+
.off(content, 'click', stop)
|
84
|
+
.off(content, 'mousedown', stop)
|
85
|
+
.off(content, 'touchstart', stop)
|
86
|
+
.off(content, 'dblclick', stop)
|
87
|
+
.off(content, 'mousewheel', stop)
|
88
|
+
.off(content, 'MozMousePixelScroll', stop);
|
89
|
+
|
90
|
+
if (this._closeButton && this._close) {
|
91
|
+
var close = this._closeButton;
|
92
|
+
|
93
|
+
L.DomEvent.off(close, 'click', this.hide, this);
|
94
|
+
}
|
95
|
+
|
96
|
+
return this;
|
97
|
+
},
|
98
|
+
|
99
|
+
isVisible: function () {
|
100
|
+
return L.DomUtil.hasClass(this._container, 'visible');
|
101
|
+
},
|
102
|
+
|
103
|
+
show: function () {
|
104
|
+
if (!this.isVisible()) {
|
105
|
+
L.DomUtil.addClass(this._container, 'visible');
|
106
|
+
if (this.options.autoPan) {
|
107
|
+
this._map.panBy([-this.getOffset() / 2, 0], {
|
108
|
+
duration: 0.5
|
109
|
+
});
|
110
|
+
}
|
111
|
+
this.fire('show');
|
112
|
+
}
|
113
|
+
},
|
114
|
+
|
115
|
+
hide: function (e) {
|
116
|
+
if (this.isVisible()) {
|
117
|
+
L.DomUtil.removeClass(this._container, 'visible');
|
118
|
+
if (this.options.autoPan) {
|
119
|
+
this._map.panBy([this.getOffset() / 2, 0], {
|
120
|
+
duration: 0.5
|
121
|
+
});
|
122
|
+
}
|
123
|
+
this.fire('hide');
|
124
|
+
}
|
125
|
+
if(e) {
|
126
|
+
L.DomEvent.stopPropagation(e);
|
127
|
+
}
|
128
|
+
},
|
129
|
+
|
130
|
+
toggle: function () {
|
131
|
+
if (this.isVisible()) {
|
132
|
+
this.hide();
|
133
|
+
} else {
|
134
|
+
this.show();
|
135
|
+
}
|
136
|
+
},
|
137
|
+
|
138
|
+
getContainer: function () {
|
139
|
+
return this._contentContainer;
|
140
|
+
},
|
141
|
+
|
142
|
+
getCloseButton: function () {
|
143
|
+
return this._closeButton;
|
144
|
+
},
|
145
|
+
|
146
|
+
setContent: function (content) {
|
147
|
+
this.getContainer().innerHTML = content;
|
148
|
+
return this;
|
149
|
+
},
|
150
|
+
|
151
|
+
getOffset: function () {
|
152
|
+
if (this.options.position === 'right') {
|
153
|
+
return -this._container.offsetWidth;
|
154
|
+
} else {
|
155
|
+
return this._container.offsetWidth;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
});
|
159
|
+
|
160
|
+
L.control.sidebar = function (placeholder, options) {
|
161
|
+
return new L.Control.Sidebar(placeholder, options);
|
162
|
+
};
|
@@ -0,0 +1,169 @@
|
|
1
|
+
.leaflet-sidebar {
|
2
|
+
position: absolute;
|
3
|
+
height: 100%;
|
4
|
+
|
5
|
+
-webkit-box-sizing: border-box;
|
6
|
+
-moz-box-sizing: border-box;
|
7
|
+
box-sizing: border-box;
|
8
|
+
padding: 10px;
|
9
|
+
|
10
|
+
z-index: 2000;
|
11
|
+
}
|
12
|
+
|
13
|
+
.leaflet-sidebar.left {
|
14
|
+
left: -500px;
|
15
|
+
transition: left 0.5s, width 0.5s;
|
16
|
+
|
17
|
+
padding-right: 0;
|
18
|
+
}
|
19
|
+
|
20
|
+
.leaflet-sidebar.right {
|
21
|
+
right: -500px;
|
22
|
+
transition: right 0.5s, width 0.5s;
|
23
|
+
|
24
|
+
padding-left: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
.leaflet-sidebar.left.visible {
|
28
|
+
left: 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
.leaflet-sidebar.right.visible {
|
32
|
+
right: 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
.leaflet-left {
|
36
|
+
transition: left 0.5s;
|
37
|
+
}
|
38
|
+
|
39
|
+
.leaflet-right {
|
40
|
+
transition: right 0.5s;
|
41
|
+
}
|
42
|
+
|
43
|
+
.leaflet-sidebar > .leaflet-control {
|
44
|
+
height: 100%;
|
45
|
+
width: 100%;
|
46
|
+
|
47
|
+
overflow: auto;
|
48
|
+
-webkit-overflow-scrolling: touch;
|
49
|
+
|
50
|
+
-webkit-box-sizing: border-box;
|
51
|
+
-moz-box-sizing: border-box;
|
52
|
+
box-sizing: border-box;
|
53
|
+
padding: 8px 24px;
|
54
|
+
|
55
|
+
font-size: 1.1em;
|
56
|
+
|
57
|
+
background: white;
|
58
|
+
box-shadow: 0 1px 7px rgba(0,0,0,0.65);
|
59
|
+
-webkit-border-radius: 4px;
|
60
|
+
border-radius: 4px;
|
61
|
+
}
|
62
|
+
|
63
|
+
.leaflet-touch .leaflet-sidebar > .leaflet-control {
|
64
|
+
box-shadow: none;
|
65
|
+
border: 2px solid rgba(0,0,0,0.2);
|
66
|
+
background-clip: padding-box;
|
67
|
+
}
|
68
|
+
|
69
|
+
@media(max-width:767px){
|
70
|
+
.leaflet-sidebar {
|
71
|
+
width: 100%;
|
72
|
+
padding: 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
.leaflet-sidebar.left {
|
76
|
+
left: -100%;
|
77
|
+
}
|
78
|
+
|
79
|
+
.leaflet-sidebar.right {
|
80
|
+
right: -100%;
|
81
|
+
}
|
82
|
+
|
83
|
+
.leaflet-sidebar.left.visible {
|
84
|
+
left: 0;
|
85
|
+
}
|
86
|
+
|
87
|
+
.leaflet-sidebar.right.visible {
|
88
|
+
right: 0;
|
89
|
+
}
|
90
|
+
|
91
|
+
.leaflet-sidebar > .leaflet-control {
|
92
|
+
box-shadow: none;
|
93
|
+
-webkit-border-radius: 0;
|
94
|
+
border-radius: 0;
|
95
|
+
}
|
96
|
+
|
97
|
+
.leaflet-sidebar.left.visible ~ .leaflet-left {
|
98
|
+
left: 100%;
|
99
|
+
}
|
100
|
+
|
101
|
+
.leaflet-sidebar.right.visible ~ .leaflet-right {
|
102
|
+
right: 100%;
|
103
|
+
}
|
104
|
+
|
105
|
+
.leaflet-touch .leaflet-sidebar > .leaflet-control {
|
106
|
+
border: 0;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
@media(min-width:768px) and (max-width:991px){
|
111
|
+
.leaflet-sidebar {
|
112
|
+
width: 305px;
|
113
|
+
}
|
114
|
+
|
115
|
+
.leaflet-sidebar.left.visible ~ .leaflet-left {
|
116
|
+
left: 305px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.leaflet-sidebar.right.visible ~ .leaflet-right {
|
120
|
+
right: 305px;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
@media(min-width:992px) and (max-width:1199px){
|
125
|
+
.leaflet-sidebar {
|
126
|
+
width: 390px;
|
127
|
+
}
|
128
|
+
|
129
|
+
.leaflet-sidebar.left.visible ~ .leaflet-left {
|
130
|
+
left: 390px;
|
131
|
+
}
|
132
|
+
|
133
|
+
.leaflet-sidebar.right.visible ~ .leaflet-right {
|
134
|
+
right: 390px;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
@media(min-width:1200px){
|
139
|
+
.leaflet-sidebar {
|
140
|
+
width: 460px;
|
141
|
+
}
|
142
|
+
|
143
|
+
.leaflet-sidebar.left.visible ~ .leaflet-left {
|
144
|
+
left: 460px;
|
145
|
+
}
|
146
|
+
|
147
|
+
.leaflet-sidebar.right.visible ~ .leaflet-right {
|
148
|
+
right: 460px;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
.leaflet-sidebar .close {
|
153
|
+
position: absolute;
|
154
|
+
right: 20px;
|
155
|
+
top: 20px;
|
156
|
+
width: 31px;
|
157
|
+
height: 31px;
|
158
|
+
|
159
|
+
color: #333;
|
160
|
+
font-size: 25pt;
|
161
|
+
line-height: 1em;
|
162
|
+
text-align: center;
|
163
|
+
background: white;
|
164
|
+
-webkit-border-radius: 16px;
|
165
|
+
border-radius: 16px;
|
166
|
+
cursor: pointer;
|
167
|
+
|
168
|
+
z-index: 8;
|
169
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leaflet-sidebar-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
@@ -17,11 +17,17 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
20
22
|
- LICENSE-leaflet-sidebar.txt
|
21
23
|
- LICENSE.txt
|
22
24
|
- README.md
|
25
|
+
- leaflet-sidebar-rails-0.0.1.gem
|
26
|
+
- leaflet-sidebar-rails.gemspec
|
23
27
|
- lib/leaflet-sidebar-rails.rb
|
24
28
|
- lib/leaflet-sidebar-rails/version.rb
|
29
|
+
- vendor/assets/javascripts/L.Control.Sidebar.js
|
30
|
+
- vendor/assets/stylesheets/L.Control.Sidebar.css
|
25
31
|
homepage: https://github.com/mejackreed/leaflet-sidebar-rails
|
26
32
|
licenses: []
|
27
33
|
metadata: {}
|