-
-
Save IrcDirk/f84d45d560dffbb827006fd86e2f81f7 to your computer and use it in GitHub Desktop.
Revisions
-
roylory revised this gist
May 13, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,16 +13,16 @@ mediaQuery = (function() { return { /** * match() returns true * if there's any match to the media query * * @param {String} str * @return {Boolean} * * ex1: mediaQuery.match('xs') * ex2: mediaQuery.match('md lg') */ match: function(str) { var arr = str.split(/[\s,|]+/); // If there's any match, return true. -
roylory renamed this gist
May 13, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
roylory created this gist
May 13, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ mediaQuery = (function() { // Same as in bootstrap/_variables.less // var screenXs = 480; // Not used var screenSm = 768; var screenMd = 992; var screenLg = 1200; var screenXsMax = screenSm - 1; var screenSmMax = screenMd - 1; var screenMdMax = screenLg - 1; return { /** * is() returns true * if there's any match to the media query * * @param {String} str * @return {Boolean} * * ex1: mediaQuery.is('xs') * ex2: mediaQuery.is('md lg') */ is: function(str) { var arr = str.split(/[\s,|]+/); // If there's any match, return true. for (var i = 0; i < arr.length; i++) { switch (arr[i]) { case 'xs': if (window.matchMedia('(max-width: ' + screenXsMax + 'px)').matches) return true; break; case 'sm': if (window.matchMedia('(min-width: ' + screenSm + 'px) and (max-width: ' + screenSmMax + 'px)').matches) return true; break; case 'md': if (window.matchMedia('(min-width: ' + screenMd + 'px) and (max-width: ' + screenMdMax + 'px)').matches) return true; break; case 'lg': if (window.matchMedia('(min-width: ' + screenLg + 'px)').matches) return true; break; } } return false; } } })();