git-svn-id: svn://euphorik.ch/pompage@45 02bbb61a-6d21-0410-aba0-cb053bdfd66a
[pompage.git] / doc / webdeveloper / dialogs / resize.js
1 // Initializes the resize dialog
2 function webdeveloper_initializeResize()
3 {
4 var resizeViewport = webdeveloper_getBooleanPreference("webdeveloper.resize.viewport", true);
5
6 document.getElementById("webdeveloper-resize-viewport").checked = resizeViewport;
7
8 // If resizing the viewport
9 if(resizeViewport)
10 {
11 document.getElementById("webdeveloper-resize-width").value = window.arguments[2];
12 document.getElementById("webdeveloper-resize-height").value = window.arguments[3];
13 }
14 else
15 {
16 document.getElementById("webdeveloper-resize-width").value = window.arguments[0];
17 document.getElementById("webdeveloper-resize-height").value = window.arguments[1];
18 }
19 }
20
21 // Resizes the parent window to the given width and height
22 function webdeveloper_resizeParentWindow()
23 {
24 var height = document.getElementById("webdeveloper-resize-height").value.trim();
25 var width = document.getElementById("webdeveloper-resize-width").value.trim();
26
27 // If the width and height are valid
28 if(width && height && (width == "*" || (parseInt(width) == width && width > 0)) && (height == "*" || (parseInt(height) == height && height > 0)))
29 {
30 var contentWindow = window.opener.content;
31 var windowX = window.opener.screenX;
32 var windowY = window.opener.screenY;
33
34 // If resizing the view port
35 if(document.getElementById("webdeveloper-resize-viewport").checked)
36 {
37 webdeveloper_setBooleanPreferenceIfNotSet("webdeveloper.resize.viewport", true);
38
39 // If the width is not a wildcard
40 if(width != "*")
41 {
42 contentWindow.innerWidth = width;
43 }
44
45 // If the height is not a wildcard
46 if(height != "*")
47 {
48 contentWindow.innerHeight = height;
49 }
50 }
51 else
52 {
53 // If the resize viewport preference is set
54 if(webdeveloper_isPreferenceSet("webdeveloper.resize.viewport"))
55 {
56 webdeveloper_deletePreference("webdeveloper.resize.viewport");
57 }
58
59 // If the width is a wildcard
60 if(width == "*")
61 {
62 width = contentWindow.outerWidth;
63 }
64
65 // If the height is a wildcard
66 if(height == "*")
67 {
68 height = contentWindow.outerHeight;
69 }
70
71 window.opener.resizeTo(width, height);
72 }
73
74 window.opener.screenX = windowX;
75 window.opener.screenY = windowY;
76 }
77 }