VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/htdocs/js/graphwiz.js@ 67787

Last change on this file since 67787 was 56295, checked in by vboxsync, 10 years ago

ValidationKit: Updated (C) year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: graphwiz.js 56295 2015-06-09 14:29:55Z vboxsync $ */
2/** @file
3 * JavaScript functions for the Graph Wizard.
4 */
5
6/*
7 *
8 * Copyright (C) 2012-2015 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29/*******************************************************************************
30* Global Variables *
31*******************************************************************************/
32/** The previous width of the div element that we measure. */
33var g_cxPreviousWidth = 0;
34
35
36/**
37 * onload function that sets g_cxPreviousWidth to the width of @a sWidthSrcId.
38 *
39 * @returns true.
40 * @param sWidthSrcId The ID of the element which width we should measure.
41 */
42function graphwizOnLoadRememberWidth(sWidthSrcId)
43{
44 var cx = getUnscaledElementWidthById(sWidthSrcId);
45 if (cx)
46 {
47 g_cxPreviousWidth = cx;
48 }
49 return true;
50}
51
52
53/**
54 * onresize callback function that scales the given graph width input field
55 * value according to the resized element.
56 *
57 * @returns true.
58 * @param sWidthSrcId The ID of the element which width we should measure
59 * the resize effect on.
60 * @param sWidthInputId The ID of the input field which values should be
61 * scaled.
62 *
63 * @remarks Since we're likely to get several resize calls as part of one user
64 * resize operation, we're likely to suffer from some rounding
65 * artifacts. So, should the user abort or undo the resizing, the
66 * width value is unlikely to be restored to the exact value it had
67 * prior to the resizing.
68 */
69function graphwizOnResizeRecalcWidth(sWidthSrcId, sWidthInputId)
70{
71 var cx = getUnscaledElementWidthById(sWidthSrcId);
72 if (cx)
73 {
74 var oElement = document.getElementById(sWidthInputId);
75 if (oElement && g_cxPreviousWidth)
76 {
77 var cxOld = oElement.value;
78 if (isInteger(cxOld))
79 {
80 var fpRatio = cxOld / g_cxPreviousWidth;
81 oElement.value = Math.round(cx * fpRatio);
82 }
83 }
84 g_cxPreviousWidth = cx;
85 }
86
87 return true;
88}
89
90/**
91 * Fills thegraph size (cx, cy) and dpi fields with default values.
92 *
93 * @returns false (for onclick).
94 * @param sWidthSrcId The ID of the element which width we should measure.
95 * @param sWidthInputId The ID of the graph width field (cx).
96 * @param sHeightInputId The ID of the graph height field (cy).
97 * @param sDpiInputId The ID of the graph DPI field.
98 */
99function graphwizSetDefaultSizeValues(sWidthSrcId, sWidthInputId, sHeightInputId, sDpiInputId)
100{
101 var cx = getUnscaledElementWidthById(sWidthSrcId);
102 var cDotsPerInch = getDeviceXDotsPerInch();
103
104 if (cx)
105 {
106 setInputFieldValue(sWidthInputId, cx);
107 setInputFieldValue(sHeightInputId, Math.round(cx * 5 / 16)); /* See wuimain.py. */
108 }
109
110 if (cDotsPerInch)
111 {
112 setInputFieldValue(sDpiInputId, cDotsPerInch);
113 }
114
115 return false;
116}
117
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette