Created
September 13, 2012 00:16
-
-
Save danny-englander/3710930 to your computer and use it in GitHub Desktop.
Revisions
-
danny-englander revised this gist
Sep 13, 2012 . 1 changed file with 2 additions and 1 deletion.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 @@ -1,5 +1,6 @@ /* * Inspired by: * http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery * * This script is ideal for getting specific class depending on device width * for enhanced theming. Media queries are fine in most cases but sometimes -
danny-englander revised this gist
Sep 13, 2012 . 1 changed file with 2 additions and 0 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 @@ -1,4 +1,6 @@ /* * originally from: http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery * * This script is ideal for getting specific class depending on device width * for enhanced theming. Media queries are fine in most cases but sometimes * you want to target a specific JQuery call based on width. This will work -
danny-englander revised this gist
Sep 13, 2012 . 1 changed file with 2 additions and 1 deletion.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 @@ -2,7 +2,8 @@ * This script is ideal for getting specific class depending on device width * for enhanced theming. Media queries are fine in most cases but sometimes * you want to target a specific JQuery call based on width. This will work * for that. Be sure to put it first in your script file. Note that you could * also target the body class instead of 'html' as well. * Modify as needed */ -
danny-englander revised this gist
Sep 13, 2012 . No changes.There are no files selected for viewing
-
danny-englander revised this gist
Sep 13, 2012 . 1 changed file with 3 additions and 1 deletion.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 @@ -1,6 +1,8 @@ /* * This script is ideal for getting specific class depending on device width * for enhanced theming. Media queries are fine in most cases but sometimes * you want to target a specific JQuery call based on width. This will work * for that. Be sure to put it first in your script file. * Modify as needed */ -
danny-englander revised this gist
Sep 13, 2012 . 1 changed file with 3 additions and 1 deletion.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 @@ -1,5 +1,7 @@ /* * This script is ideal for getting specific class depending on device width * for enhanced theming. be sure to put it first in your script file. * Modify as needed */ (function( $ ){ -
danny-englander renamed this gist
Sep 13, 2012 . 1 changed file with 1 addition and 1 deletion.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 @@ -1,5 +1,5 @@ /* *This script is ideal for getting specific class depending on device width for enhanced theming. be sure to put it first in your script file. */ (function( $ ){ -
danny-englander created this gist
Sep 13, 2012 .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,55 @@ /* *This is ideal for getting specific class depending on device width for enhanced theming. */ (function( $ ){ $(document).ready(function(){ var current_width = $(window).width(); //do something with the width value here! if(current_width < 481) $('html').addClass("m320").removeClass("m768").removeClass("desktop").removeClass("m480"); else if(current_width < 739) $('html').addClass("m768").removeClass("desktop").removeClass("m320").removeClass("tablet"); else if (current_width < 970) $('html').addClass("tablet").removeClass("desktop").removeClass("m320").removeClass("m768"); else if (current_width > 971) $('html').addClass("desktop").removeClass("m320").removeClass("m768").removeClass("tablet"); if(current_width < 650) $('html').addClass("mobile-menu").removeClass("desktop-menu"); if(current_width > 651) $('html').addClass("desktop-menu").removeClass("mobile-menu"); }); //update the width value when the browser is resized (useful for devices which switch from portrait to landscape) $(window).resize(function(){ var current_width = $(window).width(); //do something with the width value here! if(current_width < 481) $('html').addClass("m320").removeClass("m768").removeClass("desktop").removeClass("tablet"); else if(current_width < 669) $('html').addClass("m768").removeClass("desktop").removeClass("m320").removeClass("tablet"); else if (current_width < 970) $('html').addClass("tablet").removeClass("desktop").removeClass("m320").removeClass("m768"); else if (current_width > 971) $('html').addClass("desktop").removeClass("m320").removeClass("m768").removeClass("tablet"); if(current_width < 650) $('html').addClass("mobile-menu").removeClass("desktop-menu"); if(current_width > 651) $('html').addClass("desktop-menu").removeClass("mobile-menu"); }); })( jQuery );