Skip to content

Commit e3564be

Browse files
committed
Merge branch 'teamrc-sidebar-resize'
2 parents 48567d3 + 8abc031 commit e3564be

File tree

5 files changed

+63
-71
lines changed

5 files changed

+63
-71
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A stupid simple sidebar jQuery plugin.
77
*jQuery-Sidebar* is available on [CDNJS](https://cdnjs.com/libraries/jquery-sidebar) and you can use it like this:
88

99
```html
10-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.0.0/jquery.sidebar.min.js"></script>
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.1.0/jquery.sidebar.min.js"></script>
1111
```
1212

1313
## Usage
@@ -22,7 +22,7 @@ Include the script file into your HTML page:
2222
<script src="path/to/jquery.sidebar.min.js"></script>
2323
<!--
2424
or from cdnjs:
25-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.0.0/jquery.sidebar.min.js"></script>
25+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.1.0/jquery.sidebar.min.js"></script>
2626
-->
2727
...
2828
<div class="sidebar left">Hello World</div>
@@ -80,22 +80,14 @@ $(".my-sidebar").on("sidebar:closed", function () {
8080
- `side` (String): left|right|top|bottom (default: `"left"`)
8181
- `isClosed` (Boolean): A boolean value indicating if the sidebar is closed or not (default: `false`).
8282
- `close` (Boolean): If `true`, the sidebar will be closed by default.
83-
- `range` (Object): An object containing:
84-
- `left` (Array): An array with the min and max left values (default: `[-width, 0]`).
85-
- `right` (Array): An array with the min and max right values (default: `[-width, 0]`).
86-
- `top` (Array): An array with the min and max top values (default: `[-height, 0]`).
87-
- `bottom` (Array): An array with the min and max bottom values (default: `[-height, 0]`).
8883

8984
#### Return
9085
- **jQuery** The jQuery elements that were selected.
9186

92-
93-
9487
## Changelog
9588
To see the versions and the changes between them go to [releases page](https://github.com/jillix/jQuery-sidebar/releases).
9689

9790
## How to contribute
98-
9991
1. File an issue in the repository, using the bug tracker, describing the
10092
contribution you'd like to make. This will help us to get you started on the
10193
right foot.

demo.html

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<link href="http://jillix.github.io/jQuery-sidebar/css/custom.css" rel="stylesheet">
5-
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
6-
<script src="http://jillix.github.io/jQuery-sidebar/js/jquery.sidebar.min.js"></script>
7-
<script src="http://jillix.github.io/jQuery-sidebar/js/handlers.js"></script>
8-
</head>
9-
<body>
10-
<div class="container" align="center">
11-
<h1>jQuery Sidebar Demo</h3>
12-
<h3>Toggle sidebars</h3>
13-
<div>
14-
<a href="#" class="btn btn-primary" data-action="toggle" data-side="left"><span>Toggle Left</span></a>
15-
<a href="#" class="btn btn-primary" data-action="toggle" data-side="top"><span>Toggle Top</span></a>
16-
<a href="#" class="btn btn-primary" data-action="toggle" data-side="right"><span>Toggle Right</span></a>
17-
<a href="#" class="btn btn-primary" data-action="toggle" data-side="bottom"><span>Toggle Bottom</span></a>
18-
</div>
3+
<head>
4+
<link href="http://jillix.github.io/jQuery-sidebar/css/custom.css" rel="stylesheet">
5+
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
6+
<script src="./src/jquery.sidebar.js"></script>
7+
<script src="http://jillix.github.io/jQuery-sidebar/js/handlers.js"></script>
8+
</head>
9+
<body>
10+
<div class="container" align="center">
11+
<h1>jQuery Sidebar Demo</h3>
12+
<h3>Toggle sidebars</h3>
13+
<div>
14+
<a href="#" class="btn btn-primary" data-action="toggle" data-side="left"><span>Toggle Left</span></a>
15+
<a href="#" class="btn btn-primary" data-action="toggle" data-side="top"><span>Toggle Top</span></a>
16+
<a href="#" class="btn btn-primary" data-action="toggle" data-side="right"><span>Toggle Right</span></a>
17+
<a href="#" class="btn btn-primary" data-action="toggle" data-side="bottom"><span>Toggle Bottom</span></a>
18+
</div>
1919

20-
<h3>Open sidebars</h3>
21-
<section class="example-buttons" class="clearfix">
22-
<a href="#" class="btn btn-success" data-action="open" data-side="left"><span>Open Left</span></a>
23-
<a href="#" class="btn btn-success" data-action="open" data-side="top"><span>Open Top</span></a>
24-
<a href="#" class="btn btn-success" data-action="open" data-side="right"><span>Open Right</span></a>
25-
<a href="#" class="btn btn-success" data-action="open" data-side="bottom"><span>Open Bottom</span></a>
26-
</section>
20+
<h3>Open sidebars</h3>
21+
<section class="example-buttons" class="clearfix">
22+
<a href="#" class="btn btn-success" data-action="open" data-side="left"><span>Open Left</span></a>
23+
<a href="#" class="btn btn-success" data-action="open" data-side="top"><span>Open Top</span></a>
24+
<a href="#" class="btn btn-success" data-action="open" data-side="right"><span>Open Right</span></a>
25+
<a href="#" class="btn btn-success" data-action="open" data-side="bottom"><span>Open Bottom</span></a>
26+
</section>
2727

28-
<h3>Close sidebars</h3>
29-
<section class="example-buttons" class="clearfix">
30-
<a href="#" class="btn btn-danger" data-action="close" data-side="left"><span>Close Left</span></a>
31-
<a href="#" class="btn btn-danger" data-action="close" data-side="top"><span>Close Top</span></a>
32-
<a href="#" class="btn btn-danger" data-action="close" data-side="right"><span>Close Right</span></a>
33-
<a href="#" class="btn btn-danger" data-action="close" data-side="bottom"><span>Close Bottom</span></a>
34-
</section>
35-
</div>
36-
<div class="sidebars">
37-
<div class="sidebar left">Left</div>
38-
<div class="sidebar right">Right</div>
39-
<div class="sidebar top">Top</div>
40-
<div class="sidebar bottom">Bottom</div>
41-
</div>
42-
</body>
28+
<h3>Close sidebars</h3>
29+
<section class="example-buttons" class="clearfix">
30+
<a href="#" class="btn btn-danger" data-action="close" data-side="left"><span>Close Left</span></a>
31+
<a href="#" class="btn btn-danger" data-action="close" data-side="top"><span>Close Top</span></a>
32+
<a href="#" class="btn btn-danger" data-action="close" data-side="right"><span>Close Right</span></a>
33+
<a href="#" class="btn btn-danger" data-action="close" data-side="bottom"><span>Close Bottom</span></a>
34+
</section>
35+
</div>
36+
<div class="sidebars">
37+
<div class="sidebar left">Left</div>
38+
<div class="sidebar right">Right</div>
39+
<div class="sidebar top">Top</div>
40+
<div class="sidebar bottom">Bottom</div>
41+
</div>
42+
</body>
4343
</html>

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-sidebar",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "A stupid simple sidebar jQuery plugin.",
55
"main": "src/jquery.sidebar.js",
66
"scripts": {
@@ -10,15 +10,19 @@
1010
"type": "git",
1111
"url": "https://github.com/jillix/jQuery-sidebar.git"
1212
},
13+
"contributors": [
14+
"Ionică Bizău <[email protected]> (http://ionicabizau.net/)",
15+
"teamrc https://github.com/teamrc"
16+
],
1317
"keywords": [
1418
"jQuery",
1519
"sidebar",
1620
"simple"
1721
],
18-
"author": "Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net/)",
22+
"author": "jillix <contact@jillix.com>",
1923
"license": "MIT",
2024
"bugs": {
2125
"url": "https://github.com/jillix/jQuery-sidebar/issues"
2226
},
2327
"homepage": "https://github.com/jillix/jQuery-sidebar"
24-
}
28+
}

src/jquery.sidebar.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* A stupid simple sidebar jQuery plugin.
55
*
66
* Developed with <3 and JavaScript by jillix developers.
7-
* Copyright (c) 2013-14 jillix
7+
* Copyright (c) 2013-15 jillix
88
* */
99
(function($) {
1010

@@ -44,11 +44,6 @@
4444
* - `side` (String): left|right|top|bottom (default: `"left"`)
4545
* - `isClosed` (Boolean): A boolean value indicating if the sidebar is closed or not (default: `false`).
4646
* - `close` (Boolean): If `true`, the sidebar will be closed by default.
47-
* - `range` (Object): An object containing:
48-
* - `left` (Array): An array with the min and max left values (default: `[-width, 0]`).
49-
* - `right` (Array): An array with the min and max right values (default: `[-width, 0]`).
50-
* - `top` (Array): An array with the min and max top values (default: `[-height, 0]`).
51-
* - `bottom` (Array): An array with the min and max bottom values (default: `[-height, 0]`).
5247
*
5348
* @return {jQuery} The jQuery elements that were selected.
5449
*/
@@ -74,14 +69,6 @@
7469
// Side: left|right|top|bottom
7570
side: "left",
7671

77-
// Range defaults
78-
range: {
79-
left: [-width, 0],
80-
right: [-width, 0],
81-
top: [-height, 0],
82-
bottom: [-height, 0]
83-
},
84-
8572
// Is closed
8673
isClosed: false,
8774

@@ -90,16 +77,14 @@
9077

9178
}, options);
9279

93-
// Override range
94-
settings.range = settings.range[settings.side];
9580

9681
/*!
9782
* Opens the sidebar
9883
* $([jQuery selector]).trigger("sidebar:open");
9984
* */
10085
self.on("sidebar:open", function() {
10186
var properties = {};
102-
properties[settings.side] = settings.range[1];
87+
properties[settings.side] = 0;
10388
settings.isClosed = null;
10489
self.stop().animate(properties, settings.speed, function() {
10590
settings.isClosed = false;
@@ -114,7 +99,11 @@
11499
* */
115100
self.on("sidebar:close", function(callback) {
116101
var properties = {};
117-
properties[settings.side] = settings.range[0];
102+
if (settings.side === "left" || settings.side === "right") {
103+
properties[settings.side] = -self.outerWidth();
104+
} else {
105+
properties[settings.side] = -self.outerHeight();
106+
}
118107
settings.isClosed = null;
119108
self.stop().animate(properties, settings.speed, function() {
120109
settings.isClosed = true;
@@ -145,5 +134,5 @@
145134
};
146135

147136
// Version
148-
$.fn.sidebar.version = "3.0.0";
137+
$.fn.sidebar.version = "3.1.0";
149138
})(jQuery);

src/jquery.sidebar.min.js

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)