diff options
author | Richard Beales <[email protected]> | 2013-03-18 07:32:01 +0000 |
---|---|---|
committer | Richard Beales <[email protected]> | 2013-03-18 07:32:01 +0000 |
commit | 7c97d17aaf373339a8bcd917ad59ca6018148f0d (patch) | |
tree | 5a3c04f0f9529be392c1263d3feb75806eb43797 /lib/dijit/Viewport.js.uncompressed.js | |
parent | 70db7424e7068701e60cc5bcdfe8f858be508179 (diff) | |
parent | c670a80ddd9b03bd4ea6d940a9ed682fd26248d7 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib/dijit/Viewport.js.uncompressed.js')
-rw-r--r-- | lib/dijit/Viewport.js.uncompressed.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/dijit/Viewport.js.uncompressed.js b/lib/dijit/Viewport.js.uncompressed.js new file mode 100644 index 000000000..8de455af2 --- /dev/null +++ b/lib/dijit/Viewport.js.uncompressed.js @@ -0,0 +1,50 @@ +define("dijit/Viewport", [ + "dojo/Evented", + "dojo/on", + "dojo/ready", + "dojo/sniff", + "dojo/_base/window", // global + "dojo/window" // getBox() +], function(Evented, on, ready, has, win, winUtils){ + + // module: + // dijit/Viewport + + /*===== + return { + // summary: + // Utility singleton to watch for viewport resizes, avoiding duplicate notifications + // which can lead to infinite loops. + // description: + // Usage: Viewport.on("resize", myCallback). + // + // myCallback() is called without arguments in case it's _WidgetBase.resize(), + // which would interpret the argument as the size to make the widget. + }; + =====*/ + + var Viewport = new Evented(); + + ready(200, function(){ + var oldBox = winUtils.getBox(); + Viewport._rlh = on(win.global, "resize", function(){ + var newBox = winUtils.getBox(); + if(oldBox.h == newBox.h && oldBox.w == newBox.w){ return; } + oldBox = newBox; + Viewport.emit("resize"); + }); + + // Also catch zoom changes on IE8, since they don't naturally generate resize events + if(has("ie") == 8){ + var deviceXDPI = screen.deviceXDPI; + setInterval(function(){ + if(screen.deviceXDPI != deviceXDPI){ + deviceXDPI = screen.deviceXDPI; + Viewport.emit("resize"); + } + }, 500); + } + }); + + return Viewport; +}); |