Skip to content

Commit 7df9a66

Browse files
committed
Merge pull request #4 from Nikita240/no-divs
Remove HTML requirement
2 parents 2418aaa + 6ba163e commit 7df9a66

File tree

5 files changed

+24
-38
lines changed

5 files changed

+24
-38
lines changed

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ if (viewport.is('lg')) {
2828
````javascript
2929
$(window).bind('resize', function() {
3030
viewport.changed(function() {
31-
31+
3232
// do some other stuff!
33-
33+
3434
})
3535
});
3636
````
@@ -40,9 +40,9 @@ $(window).bind('resize', function() {
4040
````javascript
4141
$(window).bind('resize', function() {
4242
viewport.changed(function() {
43-
43+
4444
// do some other stuff!
45-
45+
4646
}, 600)
4747
});
4848
````
@@ -52,9 +52,9 @@ $(window).bind('resize', function() {
5252
````javascript
5353
$(window).bind('resize', function() {
5454
viewport.changed(function() {
55-
55+
5656
console.log( 'Current breakpoint: '+ viewport.current() );
57-
57+
5858
})
5959
});
6060
````
@@ -64,7 +64,7 @@ $(window).bind('resize', function() {
6464

6565
````css
6666
h1 {
67-
@include set(font-size, (xs: 20px, sm: 24px, md: 24px, lg: 30px) );
67+
@include set(font-size, (xs: 20px, sm: 24px, md: 24px, lg: 30px) );
6868
}
6969
````
7070

@@ -98,12 +98,6 @@ Output:
9898
Include just before `</body>`
9999

100100
````html
101-
<!-- Mandatory for Responsive Bootstrap Toolkit to operate -->
102-
<div class="device-xs visible-xs"></div>
103-
<div class="device-sm visible-sm"></div>
104-
<div class="device-md visible-md"></div>
105-
<div class="device-lg visible-lg"></div>
106-
107101
<!-- Responsive Bootstrap Toolkit -->
108102
<script src="js/bootstrap-toolkit.min.js"></script>
109103

@@ -125,5 +119,3 @@ Copy contents of `compass/bootstrap-toolkit` directory into your project. File `
125119
**CSS features:**
126120
1. SASS 3.3+
127121
2. Compass
128-
129-

index.html

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
1010
<!-- Include stylesheet of this example -->
1111
<link rel="stylesheet" type="text/css" href="style.css" rel="stylesheet"/>
12-
</head>
13-
12+
</head>
13+
1414
<body>
1515

1616
<div class="wrapper">
@@ -31,13 +31,6 @@ <h4>Example #1</h4>
3131

3232
</div>
3333

34-
<!-- Mandatory for Responsive Bootstrap Toolkit to operate -->
35-
<div class="device-xs visible-xs"></div>
36-
<div class="device-sm visible-sm"></div>
37-
<div class="device-md visible-md"></div>
38-
<div class="device-lg visible-lg"></div>
39-
<!-- end mandatory -->
40-
4134
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
4235
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
4336

@@ -46,5 +39,3 @@ <h4>Example #1</h4>
4639

4740
</body>
4841
</html>
49-
50-

js/bootstrap-toolkit.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,33 @@
1414
interval: 300,
1515

1616
// Breakpoint aliases
17-
breakpoints: [
18-
'xs', 'sm', 'md', 'lg'
19-
],
17+
breakpoints: {
18+
'xs': $('<div class="device-xs visible-xs"></div>').appendTo('body'),
19+
'sm': $('<div class="device-sm visible-sm"></div>').appendTo('body'),
20+
'md': $('<div class="device-md visible-md"></div>').appendTo('body'),
21+
'lg': $('<div class="device-lg visible-lg"></div>').appendTo('body')
22+
},
2023

2124
// Used to calculate intervals between consecutive function executions
2225
timer: new Date(),
2326

2427
// Returns true if current breakpoint matches passed alias
2528
is: function( alias ) {
26-
return $('.device-' + alias).is(':visible');
29+
return self.breakpoints[alias].is(':visible');
2730
},
2831

2932
// Returns current breakpoint alias
3033
current: function(){
3134
var name = 'unrecognized';
32-
self.breakpoints.forEach(function(alias){
35+
$.each(self.breakpoints, function(alias){
3336
if(self.is(alias)) {
3437
name = alias;
3538
}
3639
});
3740
return name;
3841
},
3942

40-
/*
43+
/*
4144
* Waits specified number of miliseconds before executing a function
4245
* Source: http://stackoverflow.com/a/4541963/2066118
4346
*/

js/bootstrap-toolkit.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* Version: 2.2.0 (2015-01-06)
66
* Origin: https://github.com/maciej-gurban/responsive-bootstrap-toolkit
77
*/
8-
;var ResponsiveBootstrapToolkit=function(f){var b={interval:300,breakpoints:["xs","sm","md","lg"],timer:new Date,is:function(a){return f(".device-"+a).is(":visible")},current:function(){var a="unrecognized";b.breakpoints.forEach(function(c){b.is(c)&&(a=c)});return a},changed:function(){var a={};return function(c,e){var d=d?null:b.timer.getTime();a[d]&&clearTimeout(a[d]);"undefined"===typeof e&&(e=b.interval);a[d]=setTimeout(c,e)}}()};return b}(jQuery);
8+
var ResponsiveBootstrapToolkit=function(e){var i={interval:300,breakpoints:{xs:e('<div class="device-xs visible-xs"></div>').appendTo("body"),sm:e('<div class="device-sm visible-sm"></div>').appendTo("body"),md:e('<div class="device-md visible-md"></div>').appendTo("body"),lg:e('<div class="device-lg visible-lg"></div>').appendTo("body")},timer:new Date,is:function(e){return i.breakpoints[e].is(":visible")},current:function(){var n="unrecognized";return e.each(i.breakpoints,function(e){i.is(e)&&(n=e)}),n},changed:function(){var e={};return function(n,s){var d=d?null:i.timer.getTime();if(e[d]&&clearTimeout(e[d]),"undefined"==typeof s)var s=i.interval;e[d]=setTimeout(n,s)}}()};return i}(jQuery);

js/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
);
3030
}
3131
}
32-
33-
32+
33+
3434

3535
// Executes once whole document has been loaded
3636
$(document).ready(function() {
3737

3838
resizeTopBar();
3939

40-
console.log( 'Current breakpoint:', viewport.current() );
40+
console.log( 'Current breakpoint:', viewport.current() );
4141

4242
});
4343

44-
44+
4545
// Executes each time window size changes
4646
$(window).bind('resize', function() {
4747
viewport.changed(function(){
@@ -53,5 +53,5 @@
5353
});
5454
});
5555

56-
56+
5757
})(jQuery, document, window, ResponsiveBootstrapToolkit);

0 commit comments

Comments
 (0)