Skip to content

Commit 377b208

Browse files
author
Maciej Gurban
committed
Added .use() method to specify custom visibility classes
1 parent fa5e433 commit 377b208

22 files changed

+284
-318
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.sass-cache
2-
.DS_Store
2+
.DS_Store
3+
node_modules
4+
null

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
### Changelog
22

3+
**2.5.0**
4+
Introduced `use` method allowing to use custom visibility classes. Added built-in Foundation 5 support.
5+
6+
More changes:
7+
* Changing mechanism initializing the library
8+
* Re-organizing the demos
9+
* Removing SASS-related part of the project
10+
311
**2.4.2**
412
Refactoring 'changed' method (and updating usage examples in main.js) to solve issue [#14](https://github.com/maciej-gurban/responsive-bootstrap-toolkit/issues/14).
513

@@ -15,7 +23,7 @@ Introducing comparison operators in the form of `viewport.is(">md").
1523

1624
**2.3.0**
1725

18-
Removing the requirement to insert visibility divs into the document.
26+
Removing the requirement to insert visibility divs into the document.
1927

2028
**2.2.0**
2129

README.md

Lines changed: 36 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ Current version: **2.4.2**
1515
* [Basic usage](#basic-usage)
1616
* [Execute code on window resize](#execute-code-on-window-resize)
1717
* [Get alias of current breakpoint](#get-alias-of-current-breakpoint)
18-
* [Taking precautions](#taking-precautions)
18+
* [Using with Foundation](#using-with-foundation)
19+
* [Providing your own visibility classes](#providing-your-own-visibility-classes)
1920
* [How do I include it in my project?](#how-do-i-include-it-in-my-project)
2021
* [Dependencies](#dependencies)
21-
* SASS features
22-
* [Basic usage](#sass-features)
23-
* [How do I include it in my project?](#sass-instructions)
24-
* [Dependencies](#sass-dependencies)
2522

2623
### Installation
2724
````
@@ -94,24 +91,48 @@ $(window).resize(
9491
});
9592
````
9693

97-
#### Taking precautions
94+
#### Using with Foundation
95+
96+
Instead of Bootstrap's aliases `xs`, `sm`, `md` and `lg`, Foundation uses: `small`, `medium`, `large`, and `xlarge`.
9897

99-
In certain circumstances, it might be necessary to wait for certain events to happen before executing your scripts.
10098
````javascript
101-
// Execute code only when document has been loaded fully
102-
$(document).ready(function() {
103-
if( viewport.is('xs') ) {
99+
(function($, viewport){
100+
101+
viewport.use('Foundation');
102+
103+
if( viewport.is('small') ) {
104104
// ...
105105
}
106-
});
107-
// Execute code only when all resouces have loaded
108-
$(window).load(function() {
109-
if( viewport.is('xs') ) {
106+
107+
})(jQuery, ResponsiveBootstrapToolkit);
108+
````
109+
110+
**Note:**
111+
Currently, only Foundation 5 visibility classes are supported. If you'd like to support older version of any framework, or provide your own visibility classes, refer to example below.
112+
113+
#### Providing your own visibility classes
114+
115+
````javascript
116+
(function($, viewport){
117+
118+
var visibilityDivs = {
119+
'alias-1': $('<div class="device-alias-1 your-visibility-class-1"></div>'),
120+
'alias-2': $('<div class="device-alias-2 your-visibility-class-2"></div>'),
121+
'alias-3': $('<div class="device-alias-3 your-visibility-class-3"></div>')
122+
};
123+
124+
viewport.use('Custom', visibilityDivs);
125+
126+
if( viewport.is('alias-1') ) {
110127
// ...
111128
}
112-
});
129+
130+
})(jQuery, ResponsiveBootstrapToolkit);
113131
````
114132

133+
**Note**:
134+
It's up to you to create media queries that will toggle div's visibility across different screen resolutions. How? Refer to this example.
135+
115136
#### How do I include it in my project?
116137

117138
Paste just before `</body>`
@@ -126,49 +147,3 @@ Paste just before `</body>`
126147
#### Dependencies:
127148
* jQuery
128149
* Bootstrap's responsive utility css classes (included in its standard stylesheet package)
129-
130-
131-
132-
### SASS features
133-
#### Set different CSS property value per breakpoint
134-
135-
````css
136-
h1 {
137-
@include set(font-size, (xs: 20px, sm: 24px, md: 24px, lg: 30px) );
138-
}
139-
````
140-
141-
You don't need to specify a value for each of the breakpoints. One is enough, four is the max. Example below will work just as well:
142-
143-
````css
144-
h1 {
145-
@include set(font-size, (xs: 20px, lg: 30px) );
146-
}
147-
````
148-
149-
Output:
150-
151-
````css
152-
@media (max-width: 767px) {
153-
h1 {
154-
font-size: 20px;
155-
}
156-
}
157-
@media (min-width: 1200px) {
158-
h1 {
159-
font-size: 30px;
160-
}
161-
}
162-
````
163-
164-
165-
#### SASS Instructions
166-
Copy contents of `compass/bootstrap-toolkit` directory into your project. File `style.scss` contains lines that need to be in your own style.scss for the mixin to work. You'll need SASS 3.3+.
167-
168-
To start working on project's SASS, run in project's root directory.
169-
`compass watch compass/`
170-
171-
172-
#### SASS Dependencies
173-
* SASS 3.3+
174-
* Compass

bower.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
22
"name": "responsive-bootstrap-toolkit",
3-
"version": "2.2.0",
3+
"version": "2.5.0",
44
"homepage": "https://github.com/maciej-gurban/responsive-bootstrap-toolkit",
55
"description": "Responsive Bootstrap Toolkit provides an easy way of breakpoint detection in JavaScript, detecting changes in currently active breakpoint, as well as executing any breakpoint-specific JavaScript code.",
6-
"main": "js/bootstrap-toolkit.min.js",
6+
"main": "dist/bootstrap-toolkit.js",
77
"keywords": [
88
"bootstrap",
9+
"foundation",
910
"breakpoint detection",
11+
"detect screen resolution",
1012
"responsive"
1113
],
1214
"ignore": [
13-
"index.html",
14-
"style.css",
15-
"js/main.js"
15+
"node_modules",
16+
"null"
1617
],
1718
"dependencies": {
18-
"jquery": ">= 1.9.1"
19+
"jquery": ">= 1.9.1"
1920
},
2021
"license": "MIT"
2122
}

compass/bootstrap-toolkit/_mixins.scss

Lines changed: 0 additions & 31 deletions
This file was deleted.

compass/bootstrap-toolkit/_variables.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

compass/bootstrap-toolkit/style.scss

Lines changed: 0 additions & 139 deletions
This file was deleted.

compass/config.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)