Skip to content

Commit

Permalink
made the expressions a bit more leanient on whitespace. Fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjehl committed Apr 19, 2011
1 parent 266da29 commit 79f232a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion respond.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions respond.src.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@


//find media blocks in css text, convert to style blocks //find media blocks in css text, convert to style blocks
translate = function( styles, href, media ){ translate = function( styles, href, media ){
var qs = styles.match( /@media ([^\{]+)\{([\S\s]+?)(?=\}\/\*\/mediaquery\*\/)/gmi ), var qs = styles.match( /@media ([^\{]+)\{([\S\s]+?)(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi ),
ql = qs && qs.length || 0, ql = qs && qs.length || 0,
//try to get CSS path //try to get CSS path
href = href.substring( 0, href.lastIndexOf( "/" )), href = href.substring( 0, href.lastIndexOf( "/" )),
Expand Down Expand Up @@ -116,8 +116,8 @@
mediastyles.push( { mediastyles.push( {
media : thisq.match( /(only\s+)?([a-zA-Z]+)(\sand)?/ ) && RegExp.$2, media : thisq.match( /(only\s+)?([a-zA-Z]+)(\sand)?/ ) && RegExp.$2,
rules : rules.length - 1, rules : rules.length - 1,
minw : thisq.match( /\(min\-width:\s?(\s?[0-9]+)px\s?\)/ ) && parseFloat( RegExp.$1 ), minw : thisq.match( /\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/ ) && parseFloat( RegExp.$1 ),
maxw : thisq.match( /\(max\-width:\s?(\s?[0-9]+)px\s?\)/ ) && parseFloat( RegExp.$1 ) maxw : thisq.match( /\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/ ) && parseFloat( RegExp.$1 )
} ); } );
} }
} }
Expand Down
4 changes: 3 additions & 1 deletion test/test.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ a {
body { body {
background: green; background: green;
} }
}/*/mediaquery*/ }

/*/mediaquery*/


/*styles for 620px and up!*/ /*styles for 620px and up!*/
@media screen and (min-width: 620px), only print, projector { @media screen and (min-width: 620px), only print, projector {
Expand Down

0 comments on commit 79f232a

Please sign in to comment.