Mercurial > hg > digilib
comparison xul/content/dialog_originalsize.js @ 199:49cb8a445126
restarting with version control of xul sidebar/toolbar
author | luginbue |
---|---|
date | Fri, 27 Feb 2004 11:24:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
198:c50e0e77d697 | 199:49cb8a445126 |
---|---|
1 /* | |
2 Copyright (C) 2003 WTWG, Uni Bern | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
17 | |
18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 | |
19 */ | |
20 | |
21 var VERTICAL_PIXELS = 500; | |
22 var HORIZONTAL_PIXELS = 500; | |
23 | |
24 function getCurrentOriginalSize() { | |
25 | |
26 var v_value = getSetting('originalsize_v_value'); | |
27 var v_unit = getSetting('originalsize_v_unit'); | |
28 var h_value = getSetting('originalsize_h_value'); | |
29 var h_unit = getSetting('originalsize_h_unit'); | |
30 | |
31 document.getElementById('vertical_value').setAttribute('value', v_value); | |
32 document.getElementById('horizontal_value').setAttribute('value', h_value); | |
33 | |
34 var items = document.getElementById('vertical_unit_popup').childNodes; | |
35 | |
36 for ( i = 0; i <items.length; i++ ) { | |
37 if ( items[i].getAttribute('value') == v_unit ) { | |
38 document.getElementById('vertical_unit_list').selectedItem = items[i]; | |
39 } | |
40 } | |
41 | |
42 items = document.getElementById('horizontal_unit_popup').childNodes; | |
43 | |
44 for ( i = 0; i <items.length; i++ ) { | |
45 if ( items[i].getAttribute('value') == h_unit ) { | |
46 document.getElementById('horizontal_unit_list').selectedItem = items[i]; | |
47 } | |
48 } | |
49 | |
50 } | |
51 | |
52 | |
53 function apply() { | |
54 | |
55 var v_value = document.getElementById('vertical_value').value; | |
56 var h_value = document.getElementById('horizontal_value').value; | |
57 | |
58 var v_unit; | |
59 var h_unit; | |
60 | |
61 var items = document.getElementById('vertical_unit_popup').childNodes; | |
62 | |
63 for ( i = 0; i <items.length; i++ ) { | |
64 if ( items[i].getAttribute('selected') == 'true' ) { | |
65 v_unit = items[i].getAttribute('value'); | |
66 } | |
67 } | |
68 | |
69 items = document.getElementById('vertical_unit_popup').childNodes; | |
70 | |
71 for ( i = 0; i <items.length; i++ ) { | |
72 if ( items[i].getAttribute('selected') == 'true' ) { | |
73 h_unit = items[i].getAttribute('value'); | |
74 } | |
75 } | |
76 | |
77 if ( (parseFloat(v_value) == v_value) && | |
78 (parseFloat(h_value) == h_value) ) { | |
79 | |
80 saveSetting('originalsize_v_value', v_value); | |
81 saveSetting('originalsize_v_unit', v_unit); | |
82 saveSetting('originalsize_h_value', h_value); | |
83 saveSetting('originalsize_h_unit', h_unit); | |
84 | |
85 var dpi_v = (v_unit == "inch") ? VERTICAL_PIXELS / v_value : | |
86 (v_unit == "cm") ? VERTICAL_PIXELS / (v_value/2.54) : | |
87 v_value; | |
88 | |
89 var dpi_h = (h_unit == "inch") ? VERTICAL_PIXELS / h_value : | |
90 (h_unit == "cm") ? VERTICAL_PIXELS / (h_value/2.54) : | |
91 h_value; | |
92 | |
93 opener.content.originalSize(dpi_v, dpi_h); | |
94 | |
95 close(); | |
96 | |
97 } else { | |
98 alert("Illegal value(s)!"); | |
99 } | |
100 | |
101 } | |
102 | |
103 | |
104 function cancel() { | |
105 | |
106 close(); | |
107 | |
108 } |