Skip to content

Commit

Permalink
Added if (window.outerWidth) conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
tyssen committed Apr 19, 2012
1 parent 5105126 commit 3c97415
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions readme.md
Expand Up @@ -16,6 +16,10 @@ In the plugin, changed (window).width() which requires jQuery to Math.max(screen
--------------------
Changed Math.max(screen.width,screen.height) to window.outerWidth to measure width width instead of screen width again. Reasons why jQuery's (window).width() and window.innerWidth weren't working on iOS explained in [First, Understand Your Screen](http://tripleodeon.com/2011/12/first-understand-your-screen/)

1.0.3 - 19 Apr 2012
--------------------
Added conditional to check if window.outerWidth is supported as it was [reported](http://www.johnfaulds.com.au/journal/responsive-layouts-with-expressionengine/#comment-420834555) that the cookie had a value of 'undefined' in IE.

## Credit

This is an ExpressionEngine implementation of [Simple-RESS](https://github.com/jiolasa/Simple-RESS) by Matt Stauffer.
13 changes: 11 additions & 2 deletions system/expressionengine/third_party/ress/pi.ress.php
Expand Up @@ -26,11 +26,15 @@
* Version 1.0.2 20120109
* --------------------
* Changed Math.max(screen.width,screen.height) to window.outerWidth to measure width width instead of screen width again. Reasons why jQuery's (window).width() and window.innerWidth weren't working on iOS explained in http://tripleodeon.com/2011/12/first-understand-your-screen/
*
* Version 1.0.3 20120419
* --------------------
* Added conditional to check if window.outerWidth is supported as it was reported that the cookie had a value of undefined in IE.
*/

$plugin_info = array(
'pi_name' => 'RESS',
'pi_version' =>'1.0.2',
'pi_version' =>'1.0.3',
'pi_author' =>'John Faulds',
'pi_author_url' => 'https://github.com/tyssen/RESS-ee',
'pi_description' => 'RESS (Responsive Design + Server Side Components) plugin - detect screen resolution via javascript and then set a variable to access in your templates. Useful for creating Responsive layouts that adapt to users’ screen size. Based on https://github.com/jiolasa/Simple-RESS',
Expand All @@ -48,7 +52,12 @@ public function cookie()
{
if(!isset($_COOKIE['screensize']))
{
return "<script>document.cookie='screensize='+window.outerWidth+'; path=/';location.reload(true);</script>";
return "<script>
if (window.outerWidth) {
document.cookie='screensize='+window.outerWidth+'; path=/';location.reload(true);
} else {
document.cookie='screensize='+document.documentElement.clientWidth+'; path=/';location.reload(true);
</script>";
}
}

Expand Down

0 comments on commit 3c97415

Please sign in to comment.