source: main/trunk/model-sites-dev/mozarts-laptop/collect/digital-music-stand/script/musicstand-open.js@ 30446

Last change on this file since 30446 was 30446, checked in by davidb, 8 years ago

... and the example collection (initial version)

File size: 2.2 KB
Line 
1
2 var GUITopGap = 135;
3 var GUIBotGap = 30;
4 var GUILeftRightGap = 80;
5
6 function openMusicStand(docid,pagePrefix,pageSuffix,numPages,maxPageWidth,maxPageHeight)
7 {
8
9 var screenWidth;
10 var screenHeight;
11
12 var widthRatio;
13 var heightRatio;
14
15 var ratio;
16
17 var pageWidth;
18 var pageHeight;
19
20 var musicStandWidth;
21 var musicStandHeight;
22
23
24 if (orientation == "landscape") {
25 screenWidth = screen.height - GUILeftRightGap; // leave some wiggle room
26 screenHeight = screen.width - GUITopGap - GUIBotGap; // leave some wiggle room
27
28
29 widthRatio = screenWidth / maxPageWidth;
30 heightRatio = screenHeight / maxPageHeight;
31
32 ratio = (widthRatio<heightRatio) ? widthRatio : heightRatio;
33
34 pageHeight = Math.round(maxPageWidth * ratio);
35 pageWidth = Math.round(maxPageHeight * ratio);
36
37 musicStandWidth = pageWidth + GUILeftRightGap;
38 musicStandHeight = pageHeight + GUITopGap + GUIBotGap;
39
40 }
41 else {
42 screenWidth = screen.width - GUILeftRightGap; // leave some wiggle room
43 screenHeight = screen.height - GUITopGap - GUIBotGap; // leave some wiggle room
44
45 widthRatio = screenWidth / maxPageWidth;
46 heightRatio = screenHeight / maxPageHeight;
47
48 ratio = (widthRatio<heightRatio) ? widthRatio : heightRatio;
49
50 pageWidth = Math.round(maxPageWidth * ratio);
51 pageHeight = Math.round(maxPageHeight * ratio);
52
53 musicStandWidth = pageWidth + GUILeftRightGap;
54 musicStandHeight = pageHeight + GUITopGap + GUIBotGap;
55
56 }
57
58
59 //var url = "_httpdocument_&d=" + docid + "&view=simple";
60 var url = "?a=d&ed=1&book=off&c="+gs.cgiParams["c"]+"&d=" + docid + "&excerptid=gs-document-text&view=simple";
61 var url = httpdocument + "&d=" + docid + "&excerptid=gs-document-text&view=simple";
62 url += "&pagePrefix="+pagePrefix;
63 url += "&pageSuffix="+pageSuffix;
64 url += "&numPages="+numPages;
65 url += "&pageWidth="+pageWidth+"&pageHeight="+pageHeight;
66 url += "&scaleFactor="+ratio;
67
68
69 var options = 'toolbar=0,menubar=0,location=0,directories=0,scrollbars=0,status=1';
70 options += ',width='+musicStandWidth+',height='+musicStandHeight;
71
72 window.open(url, 'musicstand', options);
73
74 return false;
75 }
76
Note: See TracBrowser for help on using the repository browser.