Skip to content

Commit 4732896

Browse files
committed
Merge pull request #31 from maciej-gurban/develop
Release candidate 2.5.1
2 parents c73939b + abee292 commit 4732896

File tree

5 files changed

+66
-60
lines changed

5 files changed

+66
-60
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### Changelog
22

3+
**2.5.1**
4+
Delaying the injection of visibility div container into `body` until `$(document).ready()`, and thus allowing the inclusion of library inside `<head>` section.
5+
36
**2.5.0**
47
Introduced `use` method allowing to use custom visibility classes. Added built-in Foundation 5 support.
58

README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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. Despite the name, you can use it also with Foundation, or any other framework.
44

5-
Current version: **2.5.0**
5+
Current version: **2.5.1**
66

77
### Documentation
88
* [Installation](#installation)
@@ -36,31 +36,32 @@ Live example available on [CodePen](http://codepen.io/dih/full/ivECj). Hosted al
3636
````javascript
3737
// Wrap IIFE around your code
3838
(function($, viewport){
39-
40-
// Executes only in XS breakpoint
41-
if( viewport.is('xs') ) {
42-
// ...
43-
}
44-
45-
// Executes in SM, MD and LG breakpoints
46-
if( viewport.is('>=sm') ) {
47-
// ...
48-
}
49-
50-
// Executes in XS and SM breakpoints
51-
if( viewport.is('<md') ) {
52-
// ...
53-
}
54-
55-
// Execute code each time window size changes
56-
$(window).resize(
57-
viewport.changed(function(){
58-
if( viewport.is('xs') ) {
59-
// ...
60-
}
61-
})
62-
);
63-
39+
$(document).ready(function() {
40+
41+
// Executes only in XS breakpoint
42+
if(viewport.is('xs')) {
43+
// ...
44+
}
45+
46+
// Executes in SM, MD and LG breakpoints
47+
if(viewport.is('>=sm')) {
48+
// ...
49+
}
50+
51+
// Executes in XS and SM breakpoints
52+
if(viewport.is('<md')) {
53+
// ...
54+
}
55+
56+
// Execute code each time window size changes
57+
$(window).resize(
58+
viewport.changed(function() {
59+
if(viewport.is('xs')) {
60+
// ...
61+
}
62+
})
63+
);
64+
});
6465
})(jQuery, ResponsiveBootstrapToolkit);
6566
````
6667

@@ -69,7 +70,7 @@ Allows using custom debounce interval. The default one is set at 300ms.
6970

7071
````javascript
7172
$(window).resize(
72-
viewport.changed(function(){
73+
viewport.changed(function() {
7374

7475
// ...
7576

@@ -80,8 +81,8 @@ $(window).resize(
8081
#### Get alias of current breakpoint
8182
````javascript
8283
$(window).resize(
83-
viewport.changed(function(){
84-
console.log( 'Current breakpoint: '+ viewport.current() );
84+
viewport.changed(function() {
85+
console.log('Current breakpoint: ', viewport.current());
8586
})
8687
);
8788
````
@@ -95,7 +96,7 @@ Instead of Bootstrap's aliases `xs`, `sm`, `md` and `lg`, Foundation uses: `smal
9596

9697
viewport.use('Foundation');
9798

98-
if( viewport.is('small') ) {
99+
if(viewport.is('small')) {
99100
// ...
100101
}
101102

@@ -118,7 +119,7 @@ Currently, only Foundation 5 visibility classes are supported. If you'd like to
118119

119120
viewport.use('Custom', visibilityDivs);
120121

121-
if( viewport.is('alias-1') ) {
122+
if(viewport.is('alias-1')) {
122123
// ...
123124
}
124125

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "responsive-bootstrap-toolkit",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
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.",
66
"main": "dist/bootstrap-toolkit.js",

dist/bootstrap-toolkit.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,44 @@
22
* Responsive Bootstrap Toolkit
33
* Author: Maciej Gurban
44
* License: MIT
5-
* Version: 2.5.0 (2015-05-14)
5+
* Version: 2.5.1 (2015-11-02)
66
* Origin: https://github.com/maciej-gurban/responsive-bootstrap-toolkit
77
*/
8-
var ResponsiveBootstrapToolkit = (function($){
8+
;var ResponsiveBootstrapToolkit = (function($){
99

1010
// Internal methods
1111
var internal = {
1212

1313
/**
1414
* Breakpoint detection divs for each framework version
1515
*/
16-
detectionDivs: {
17-
// Bootstrap 3
18-
bootstrap: {
19-
'xs': $('<div class="device-xs visible-xs visible-xs-block"></div>'),
20-
'sm': $('<div class="device-sm visible-sm visible-sm-block"></div>'),
21-
'md': $('<div class="device-md visible-md visible-md-block"></div>'),
22-
'lg': $('<div class="device-lg visible-lg visible-lg-block"></div>')
23-
},
24-
// Foundation 5
25-
foundation: {
26-
'small': $('<div class="device-xs show-for-small-only"></div>'),
27-
'medium': $('<div class="device-sm show-for-medium-only"></div>'),
28-
'large': $('<div class="device-md show-for-large-only"></div>'),
29-
'xlarge': $('<div class="device-lg show-for-xlarge-only"></div>')
30-
}
31-
},
16+
detectionDivs: {
17+
// Bootstrap 3
18+
bootstrap: {
19+
'xs': $('<div class="device-xs visible-xs visible-xs-block"></div>'),
20+
'sm': $('<div class="device-sm visible-sm visible-sm-block"></div>'),
21+
'md': $('<div class="device-md visible-md visible-md-block"></div>'),
22+
'lg': $('<div class="device-lg visible-lg visible-lg-block"></div>')
23+
},
24+
// Foundation 5
25+
foundation: {
26+
'small': $('<div class="device-xs show-for-small-only"></div>'),
27+
'medium': $('<div class="device-sm show-for-medium-only"></div>'),
28+
'large': $('<div class="device-md show-for-large-only"></div>'),
29+
'xlarge': $('<div class="device-lg show-for-xlarge-only"></div>')
30+
}
31+
},
3232

3333
/**
3434
* Append visibility divs after DOM laoded
3535
*/
36-
applyDetectionDivs: function() {
37-
$(document).ready(function(){
38-
$.each(self.breakpoints, function(alias){
39-
self.breakpoints[alias].appendTo('.responsive-bootstrap-toolkit');
40-
});
41-
});
42-
},
36+
applyDetectionDivs: function() {
37+
$(document).ready(function(){
38+
$.each(self.breakpoints, function(alias){
39+
self.breakpoints[alias].appendTo('.responsive-bootstrap-toolkit');
40+
});
41+
});
42+
},
4343

4444
/**
4545
* Determines whether passed string is a parsable expression
@@ -221,7 +221,9 @@ var ResponsiveBootstrapToolkit = (function($){
221221
};
222222

223223
// Create a placeholder
224-
$('<div class="responsive-bootstrap-toolkit"></div>').appendTo('body');
224+
$(document).ready(function(){
225+
$('<div class="responsive-bootstrap-toolkit"></div>').appendTo('body');
226+
});
225227

226228
if( self.framework === null ) {
227229
self.use('bootstrap');

dist/bootstrap-toolkit.min.js

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

0 commit comments

Comments
 (0)