[Pkg-javascript-commits] [dojo] 18/87: Fixes #14458. Backport [27391] to branch/1.7 and shave some bytes. !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.7.5
in repository dojo.

commit 12579559af5cf4a2f71ba9d4b12ac3b77a4ec1a4
Author: Douglas Hays <doughays at dojotoolkit.org>
Date:   Thu Dec 15 13:42:16 2011 +0000

    Fixes #14458.  Backport [27391] to branch/1.7 and shave some bytes. !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.7/dojo@27423 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 window.js | 56 ++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/window.js b/window.js
index 852abda..25b0fda 100644
--- a/window.js
+++ b/window.js
@@ -1,31 +1,51 @@
-define(["./_base/kernel", "./_base/lang", "./_base/sniff", "./_base/window", "./dom", "./dom-geometry", "./dom-style"], function(dojo, lang, has, baseWindow, dom, geom, style) {
-	// module:
-	//		dojo/window
-	// summary:
-	//		TODOC
+define(["./_base/lang", "./_base/sniff", "./_base/window", "./dom", "./dom-geometry", "./dom-style"],
+	function(lang, has, baseWindow, dom, geom, style) {
+
+// module:
+//		dojo/window
+// summary:
+//		TODOC
 
-lang.getObject("window", true, dojo);
+var window = lang.getObject("dojo.window", true);
 
-dojo.window.getBox = function(){
+/*=====
+dojo.window = {
 	// summary:
-	//		Returns the dimensions and scroll position of the viewable area of a browser window
+	//		TODO
+};
+window = dojo.window;
+=====*/
 
-	var scrollRoot = (baseWindow.doc.compatMode == 'BackCompat') ? baseWindow.body() : baseWindow.doc.documentElement;
+window.getBox = function(){
+	// summary:
+	//		Returns the dimensions and scroll position of the viewable area of a browser window
 
-	// get scroll position
-	var scroll = geom.docScroll(); // scrollRoot.scrollTop/Left should work
+	var
+		scrollRoot = (baseWindow.doc.compatMode == 'BackCompat') ? baseWindow.body() : baseWindow.doc.documentElement,
+		// get scroll position
+		scroll = geom.docScroll(), // scrollRoot.scrollTop/Left should work
+		w, h;
 
-	var uiWindow = baseWindow.doc.parentWindow || baseWindow.doc.defaultView;   // use UI window, not dojo.global window
-	// dojo.global.innerWidth||dojo.global.innerHeight is for mobile
+	if(has("touch")){ // if(scrollbars not supported)
+		var uiWindow = baseWindow.doc.parentWindow || baseWindow.doc.defaultView;   // use UI window, not dojo.global window. baseWindow.doc.parentWindow probably not needed since it's not defined for webkit
+		// on mobile, scrollRoot.clientHeight <= uiWindow.innerHeight <= scrollRoot.offsetHeight, return uiWindow.innerHeight
+		w = uiWindow.innerWidth || scrollRoot.clientWidth; // || scrollRoot.clientXXX probably never evaluated
+		h = uiWindow.innerHeight || scrollRoot.clientHeight;
+	}else{
+		// on desktops, scrollRoot.clientHeight <= scrollRoot.offsetHeight <= uiWindow.innerHeight, return scrollRoot.clientHeight
+		// uiWindow.innerWidth/Height includes the scrollbar and cannot be used
+		w = scrollRoot.clientWidth;
+		h = scrollRoot.clientHeight;
+	}
 	return {
 		l: scroll.x,
 		t: scroll.y,
-		w: uiWindow.innerWidth || scrollRoot.clientWidth,
-		h: uiWindow.innerHeight || scrollRoot.clientHeight
+		w: w,
+		h: h
 	};
 };
 
-dojo.window.get = function(doc){
+window.get = function(doc){
 	// summary:
 	// 		Get window object associated with document doc
 
@@ -49,7 +69,7 @@ dojo.window.get = function(doc){
 	return doc.parentWindow || doc.defaultView;	//	Window
 };
 
-dojo.window.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){
+window.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){
 	// summary:
 	//		Scroll the passed node into view, if it is not already.
 
@@ -145,5 +165,5 @@ dojo.window.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){
 	}
 };
 
-return dojo.window;
+return window;
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list