[
  {
    "path": ".gitignore",
    "content": "# Compiled Python files\n*.pyc\n\n# Folder view configuration files\n.DS_Store\nDesktop.ini\n\n# Thumbnail cache files\n._*\nThumbs.db\n\n# Files that might appear on external disks\n.Spotlight-V100\n.Trashes\n\n# IntelliJ\n*.iml\n*.ipr\n*.iws\n.idea\n\n# npm\nnode_modules"
  },
  {
    "path": "Makefile",
    "content": "UGLIFY=./node_modules/uglify-js/bin/uglifyjs\n\ndetect-zoom.min.js: detect-zoom.js\n\t$(UGLIFY) detect-zoom.js -c > detect-zoom.min.js\n"
  },
  {
    "path": "README.md",
    "content": "Cross Browser Zoom and Pixel Ratio Detector\n======\n------\n\n### READ THIS: Detect-zoom is currently unusable for desktop\n\nLast update: Aug 7 2013\n\n**In the past few months both Mozilla and Google made some changes to their browsers that make it almost impossible to do \nwhat detect-zoom is here to do:**\n\n#### Firefox\nOn *Firefox 18* Mozilla changes the `devicePixelRatio` value on manual zoom (cmd/ctrl +/-), making it impossible\nto know whether the browser is in zoom mode or is it a retina device, ignoring what the word DEVICE represents.  \nI personally believe someone there refuses to admit this is a mistake and revert this decision.\n\n#### Chrome\nOn *Chrome 27* (Meaning WebKit and Blink) `webkitTextSizeAdjust` was deprecated on desktops versions of the browser. \nThis was the only bullet proof way to detect zoom in desktop chrome that I am aware of.  \nThere are couple of other ways, but they don't cover all the bases - one uses SVG but is not working in iFrames, the other \nuses window.inner/outerWidth and is not working when there is a sidebar or the DevTools are open on the side.\n\n### Other Known issues:\n* In some multi-monitor enviroments where each monitor has a different 'pixel aspect ratio' windows that span accross both monitors might return false pixelAspectRatio values.\n\nWhat is this for?\n------\nDetecting the browser zoom level and device pixel ratio relative to the zoom level.\n\nIt can be used to show higher-resolution `canvas` or `img` when necessary,\nto warn users that your site's layout will be broken in their current zoom level,\nand much more.\nPersonally I'm maintaining it to use Detect-zoom in [Wix.com](http://wix.com)'s editor to warn users\nthat their browser is in zoom mode before saving important changes to their website.\n\nWhat happend to @yonran?\n------\nDon't worry, he is well.\nAs of January 2013 [@yonran](https://github.com/yonran) stopped maintaining his source of detect-zoom, and transferred the repository to me.\nIf you are looking to update previous versions note that there were some breaking changes\n\n* **Major Changes from the latest yonran version:**\n    * `DetectZoom` object name changed to `detectZoom`\n    * `DetectZoom.ratio()` is no longer publicly accessible\n    * Supported browsers: IE8+, FF4+, modern Webkit, mobile Webkit, Opera 11.1+\n    * *IE6, IE7, FF 3.6 and Opera 10.x are no longer supported*\n    * Added support to be loaded as an AMD and CommonJS module\n\nLive Example\n------\nSee the Live Example section in\nhttp://tombigel.github.com/detect-zoom/\n\nUsage\n------\n**Detect-zoom has only two public functions:**\n* `zoom()`   Returns the zoom level of the user's browser using Javascript.\n* `device()`   Returns the device pixel ratio multiplied by the zoom level (Read [more about devicePixelRatio](http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html) at QuirksMode)\n\n```html\n<script src=\"detect-zoom.js\"></script>\n<script>\n  var zoom = detectZoom.zoom();\n  var device = detectZoom.device();\n\n  console.log(zoom, device);\n</script>\n```\n\n**AMD Usage**\n\n```javascript\nrequire(['detect-zoom'], function(detectZoom){\n    var zoom = detectZoom.zoom();\n});\n```\n\n**Installing with NPM**\n\n```bash\n> npm install detect-zoom\n```\n\nChangelog\n------\n\n2013/4/01\n* Changed WebKit detection from deprecated webkitTextSizeAdjust to webkitMarquee\n* Changed WebKitMobile detection from unreliable 'ontouchstart' event (can be triggered on desktops too) to 'orientation' property that is hopefully more reliable\n* Minor version bump to 1.0.4\n\n2013/3/29\n* Added package.json (thanks [@TCampaigne](https://github.com/TCampaigne))\n* Some documentation fixes\n* Added detect-zoom to npm package manager (again, thanks [@TCampaigne](https://github.com/TCampaigne)) \n\n2013/2/25\n* Fixed a missing 'else' between ie8 and ie10 detection\n* Minor version bump to 1.0.2\n\n2013/2/15\n* Added a fix for IE10 Metro (or whatever MS calls it these days..) by [@stefanvanburen](https://github.com/stefanvanburen)\n* Minor version bump to 1.0.1\n* Added minimized version\n\n2013/2/05\n* Merged a pull request that fixed zoom on IE being returned X100 (thanks [@kreymerman](https://github.com/kreymerman))\n* Refactored the code some more, changed some function names\n* Browser dependent main function is created only on initialization (thanks [@jsmaker](https://github.com/jsmaker))\n* _Open Issue: Firefox returns `zoom` and `devicePixelRatio` the same. Still looking for a solution here._\n* Started versioning - this is version 1.0.0\n\n2013/1/27\n* Added a fix to Mozilla's (Broken as I see it - https://bugzilla.mozilla.org/show_bug.cgi?id=809788)\nimplementation of window.devicePixel starting Firefox 18\n\n2013/1/26\n* Repository moved here\n* Refactored most of the code\n* Removed support for older browsers\n* Added support for AMD and CommonJS\n\n\nHelp Needed\n------\n\n***Detect-zoom is not complete, many parts of the code are 6 to 12 months old and I'm still reviewing them\nI need help testing different browsers, finding better ways to measure zoom on problematic browsers (ahm.. Firefox.. ahm)\npatches are more than welcome.***\n\n\nLicense\n------\n\nDetect-zoom is dual-licensed under the [WTFPL](http://www.wtfpl.net/about/) and [MIT](http://opensource.org/licenses/MIT) license, at the recipient's choice.\n"
  },
  {
    "path": "detect-zoom.js",
    "content": "/* Detect-zoom\n * -----------\n * Cross Browser Zoom and Pixel Ratio Detector\n * Version 1.0.4 | Apr 1 2013\n * dual-licensed under the WTFPL and MIT license\n * Maintained by https://github/tombigel\n * Original developer https://github.com/yonran\n */\n\n//AMD and CommonJS initialization copied from https://github.com/zohararad/audio5js\n(function (root, ns, factory) {\n    \"use strict\";\n\n    if (typeof (module) !== 'undefined' && module.exports) { // CommonJS\n        module.exports = factory(ns, root);\n    } else if (typeof (define) === 'function' && define.amd) { // AMD\n        define(\"detect-zoom\", function () {\n            return factory(ns, root);\n        });\n    } else {\n        root[ns] = factory(ns, root);\n    }\n\n}(window, 'detectZoom', function () {\n\n    /**\n     * Use devicePixelRatio if supported by the browser\n     * @return {Number}\n     * @private\n     */\n    var devicePixelRatio = function () {\n        return window.devicePixelRatio || 1;\n    };\n\n    /**\n     * Fallback function to set default values\n     * @return {Object}\n     * @private\n     */\n    var fallback = function () {\n        return {\n            zoom: 1,\n            devicePxPerCssPx: 1\n        };\n    };\n    /**\n     * IE 8 and 9: no trick needed!\n     * TODO: Test on IE10 and Windows 8 RT\n     * @return {Object}\n     * @private\n     **/\n    var ie8 = function () {\n        var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\n    };\n\n    /**\n     * For IE10 we need to change our technique again...\n     * thanks https://github.com/stefanvanburen\n     * @return {Object}\n     * @private\n     */\n    var ie10 = function () {\n        var zoom = Math.round((document.documentElement.offsetHeight / window.innerHeight) * 100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\n    };\n\n\t/**\n\t* For chrome\n\t*\n\t*/\n    var chrome = function()\n    {\n    \tvar zoom = Math.round(((window.outerWidth) / window.innerWidth)*100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\t    \n    }\n\n\t/**\n\t* For safari (same as chrome)\n\t*\n\t*/\n    var safari= function()\n    {\n    \tvar zoom = Math.round(((document.documentElement.clientWidth) / window.innerWidth)*100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\t    \n    }\n\t\n\n    /**\n     * Mobile WebKit\n     * the trick: window.innerWIdth is in CSS pixels, while\n     * screen.width and screen.height are in system pixels.\n     * And there are no scrollbars to mess up the measurement.\n     * @return {Object}\n     * @private\n     */\n    var webkitMobile = function () {\n        var deviceWidth = (Math.abs(window.orientation) == 90) ? screen.height : screen.width;\n        var zoom = deviceWidth / window.innerWidth;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\n    };\n\n    /**\n     * Desktop Webkit\n     * the trick: an element's clientHeight is in CSS pixels, while you can\n     * set its line-height in system pixels using font-size and\n     * -webkit-text-size-adjust:none.\n     * device-pixel-ratio: http://www.webkit.org/blog/55/high-dpi-web-sites/\n     *\n     * Previous trick (used before http://trac.webkit.org/changeset/100847):\n     * documentElement.scrollWidth is in CSS pixels, while\n     * document.width was in system pixels. Note that this is the\n     * layout width of the document, which is slightly different from viewport\n     * because document width does not include scrollbars and might be wider\n     * due to big elements.\n     * @return {Object}\n     * @private\n     */\n    var webkit = function () {\n        var important = function (str) {\n            return str.replace(/;/g, \" !important;\");\n        };\n\n        var div = document.createElement('div');\n        div.innerHTML = \"1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>0\";\n        div.setAttribute('style', important('font: 100px/1em sans-serif; -webkit-text-size-adjust: none; text-size-adjust: none; height: auto; width: 1em; padding: 0; overflow: visible;'));\n\n        // The container exists so that the div will be laid out in its own flow\n        // while not impacting the layout, viewport size, or display of the\n        // webpage as a whole.\n        // Add !important and relevant CSS rule resets\n        // so that other rules cannot affect the results.\n        var container = document.createElement('div');\n        container.setAttribute('style', important('width:0; height:0; overflow:hidden; visibility:hidden; position: absolute;'));\n        container.appendChild(div);\n\n        document.body.appendChild(container);\n        var zoom = 1000 / div.clientHeight;\n        zoom = Math.round(zoom * 100) / 100;\n        document.body.removeChild(container);\n\n        return{\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\n    };\n\n    /**\n     * no real trick; device-pixel-ratio is the ratio of device dpi / css dpi.\n     * (Note that this is a different interpretation than Webkit's device\n     * pixel ratio, which is the ratio device dpi / system dpi).\n     *\n     * Also, for Mozilla, there is no difference between the zoom factor and the device ratio.\n     *\n     * @return {Object}\n     * @private\n     */\n    var firefox4 = function () {\n        var zoom = mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001);\n        zoom = Math.round(zoom * 100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom\n        };\n    };\n\n    /**\n     * Firefox 18.x\n     * Mozilla added support for devicePixelRatio to Firefox 18,\n     * but it is affected by the zoom level, so, like in older\n     * Firefox we can't tell if we are in zoom mode or in a device\n     * with a different pixel ratio\n     * @return {Object}\n     * @private\n     */\n    var firefox18 = function () {\n        return {\n            zoom: firefox4().zoom,\n            devicePxPerCssPx: devicePixelRatio()\n        };\n    };\n\n    /**\n     * works starting Opera 11.11\n     * the trick: outerWidth is the viewport width including scrollbars in\n     * system px, while innerWidth is the viewport width including scrollbars\n     * in CSS px\n     * @return {Object}\n     * @private\n     */\n    var opera11 = function () {\n        var zoom = window.top.outerWidth / window.top.innerWidth;\n        zoom = Math.round(zoom * 100) / 100;\n        return {\n            zoom: zoom,\n            devicePxPerCssPx: zoom * devicePixelRatio()\n        };\n    };\n\n    /**\n     * Use a binary search through media queries to find zoom level in Firefox\n     * @param property\n     * @param unit\n     * @param a\n     * @param b\n     * @param maxIter\n     * @param epsilon\n     * @return {Number}\n     */\n    var mediaQueryBinarySearch = function (property, unit, a, b, maxIter, epsilon) {\n        var matchMedia;\n        var head, style, div;\n        if (window.matchMedia) {\n            matchMedia = window.matchMedia;\n        } else {\n            head = document.getElementsByTagName('head')[0];\n            style = document.createElement('style');\n            head.appendChild(style);\n\n            div = document.createElement('div');\n            div.className = 'mediaQueryBinarySearch';\n            div.style.display = 'none';\n            document.body.appendChild(div);\n\n            matchMedia = function (query) {\n                style.sheet.insertRule('@media ' + query + '{.mediaQueryBinarySearch ' + '{text-decoration: underline} }', 0);\n                var matched = getComputedStyle(div, null).textDecoration == 'underline';\n                style.sheet.deleteRule(0);\n                return {matches: matched};\n            };\n        }\n        var ratio = binarySearch(a, b, maxIter);\n        if (div) {\n            head.removeChild(style);\n            document.body.removeChild(div);\n        }\n        return ratio;\n\n        function binarySearch(a, b, maxIter) {\n            var mid = (a + b) / 2;\n            if (maxIter <= 0 || b - a < epsilon) {\n                return mid;\n            }\n            var query = \"(\" + property + \":\" + mid + unit + \")\";\n            if (matchMedia(query).matches) {\n                return binarySearch(mid, b, maxIter - 1);\n            } else {\n                return binarySearch(a, mid, maxIter - 1);\n            }\n        }\n    };\n\n    /**\n     * Generate detection function\n     * @private\n     */\n    var detectFunction = (function () {\n        var func = fallback;\n        //IE8+\n        if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {\n            func = ie8;\n        }\n        // IE10+ / Touch\n        else if (window.navigator.msMaxTouchPoints) {\n            func = ie10;\n        }\n\t\t//chrome\n\t\telse if(!!window.chrome && !(!!window.opera || navigator.userAgent.indexOf(' Opera') >= 0)){\n\t\t\tfunc = chrome;\n\t\t}\n\t\t//safari\n\t\telse if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0){\n\t\t\tfunc = safari;\n\t\t}\t\n        //Mobile Webkit\n        else if ('orientation' in window && 'webkitRequestAnimationFrame' in window) {\n            func = webkitMobile;\n        }\n        //WebKit\n        else if ('webkitRequestAnimationFrame' in window) {\n            func = webkit;\n        }\n        //Opera\n        else if (navigator.userAgent.indexOf('Opera') >= 0) {\n            func = opera11;\n        }\n        //Last one is Firefox\n        //FF 18.x\n        else if (window.devicePixelRatio) {\n            func = firefox18;\n        }\n        //FF 4.0 - 17.x\n        else if (firefox4().zoom > 0.001) {\n            func = firefox4;\n        }\n\n        return func;\n    }());\n\n\n    return ({\n\n        /**\n         * Ratios.zoom shorthand\n         * @return {Number} Zoom level\n         */\n        zoom: function () {\n            return detectFunction().zoom;\n        },\n\n        /**\n         * Ratios.devicePxPerCssPx shorthand\n         * @return {Number} devicePxPerCssPx level\n         */\n        device: function () {\n            return detectFunction().devicePxPerCssPx;\n        }\n    });\n}));\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"detect-zoom\",\n  \"version\": \"1.0.4\",\n  \"description\": \"Cross Browser Zoom and Pixel Ratio Detector\",\n  \"main\": \"detect-zoom.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/tombigel/detect-zoom.git\"\n  },\n  \"keywords\": [\n    \"browser\",\n    \"zoom\",\n    \"compatibility\",\n    \"pixel\",\n    \"ratio\",\n    \"retina\"\n  ],\n  \"author\": \"Yonathan Randolph\",\n  \"contributors\": [\n    \"Tom Bigelajzen <public@tombigel.com>\"\n  ],\n  \"license\": \"MIT\",\n  \"readmeFilename\": \"README.md\",\n  \"gitHead\": \"6eaf3107a6913a4f7b93665ba6d5bc16cdf0f3ab\",\n  \"devDependencies\": {\n    \"uglify-js\": \"~3.6.6\"\n  }\n}\n"
  }
]