Make WordPress Core

Ticket #27650: dev_tool_window_size.php

File dev_tool_window_size.php, 3.3 KB (added by zipzit, 11 years ago)

Plugin I wrote that help exhibits the error.

Line 
1<?php
2/**
3 * Plugin Name: Dev Tool Window Size Plugin
4 * Plugin URI:
5 * Description: This plugin pastes a tiny fixed box on the screen that shows height x width of the browser window. Very handy tool during responsive web site development to ensure your CSS @media calls are performing correctly. By dragging the edge of your browser program narrow, you can quickly simulate your website's appearance on a smart phone or tablet device.  You get immediate feedback as to the size of the browser window.  Please remember to deactive this plugin before making your website visible to customers.
6 * Version:  1.0
7 * Author: Zip Zit
8 * Author URI: mailto:zipzit@yahoo.com
9 *  Copyright 2014  Zip Zit  (email : zipzit@yahoo.com)
10 */
11
12/*  This program is free software; you can redistribute it and/or modify
13    it under the terms of the GNU General Public License, version 2, as
14    published by the Free Software Foundation.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24*/
25
26function dev_tool_window_size(){
27?>
28    <div id="dev_tool_window_size" style="position: fixed; top:33; right:0; min-width:50px; background-color: blue; color: white; z-index: 100000;">
29    window size
30    </div>
31
32    <script type="text/javascript">
33
34    function checkScreenSize(){ 
35        var winW = 630, winH = 460;
36        if (document.body && document.body.offsetWidth) {
37         winW = document.body.offsetWidth;
38         winH = document.body.offsetHeight;
39        }
40        if (document.compatMode=='CSS1Compat' &&
41            document.documentElement &&
42            document.documentElement.offsetWidth ) {
43         winW = document.documentElement.offsetWidth;
44         winH = document.documentElement.offsetHeight;
45        }
46        if (window.innerWidth && window.innerHeight) {
47         winW = window.innerWidth;
48         winH = window.innerHeight;
49        }
50
51        document.getElementById('dev_tool_window_size').innerHTML= 'window size: &nbsp;'+ winW +'x'+ winH +'px';
52    }
53
54        //  ref:  http://stackoverflow.com/questions/8575772/how-to-detect-in-jquery-if-screen-resolution-changes  */
55        // shim layer with setTimeout fallback
56        window.requestAnimFrame = (function(){
57          return  window.requestAnimationFrame       ||
58                  window.webkitRequestAnimationFrame ||
59                  window.mozRequestAnimationFrame    ||
60                  window.oRequestAnimationFrame      ||
61                  window.msRequestAnimationFrame     ||
62                  function( callback ){
63                    window.setTimeout(callback, 1000 / 4);  /* update 60 per second?  4 times per second is just fine.  */
64                  };
65        })();
66
67        // usage:
68        // instead of setInterval(checkScreenSize, 50) ....
69        (function loop(){
70          requestAnimFrame(loop);
71          checkScreenSize();
72        })();
73
74
75    </script>
76<?php 
77}
78
79add_action('wp_loaded', 'dev_tool_window_size' );
80
81?>