Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added if (window.outerWidth) conditional

  • Loading branch information...
commit 1ad5f70c7b6e94b5c57fb7fa43614bf1890bc6f3 1 parent 5105126
@tyssen authored
Showing with 15 additions and 2 deletions.
  1. +4 −0 readme.md
  2. +11 −2 system/expressionengine/third_party/ress/pi.ress.php
View
4 readme.md
@@ -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 [http://www.johnfaulds.com.au/journal/responsive-layouts-with-expressionengine/#comment-420834555](reported) 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.
View
13 system/expressionengine/third_party/ress/pi.ress.php
@@ -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',
@@ -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>";
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.