You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/03/16 13:29:43 UTC
svn commit: r1301461 - in /incubator/wookie/trunk/widgets/sharedraw:
config.xml index.html scripts/draw.js
Author: scottbw
Date: Fri Mar 16 12:29:42 2012
New Revision: 1301461
URL: http://svn.apache.org/viewvc?rev=1301461&view=rev
Log:
Made the sharedraw widget scale nicely to fit the available viewport, and never have scrollbars
Modified:
incubator/wookie/trunk/widgets/sharedraw/config.xml
incubator/wookie/trunk/widgets/sharedraw/index.html
incubator/wookie/trunk/widgets/sharedraw/scripts/draw.js
Modified: incubator/wookie/trunk/widgets/sharedraw/config.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/sharedraw/config.xml?rev=1301461&r1=1301460&r2=1301461&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/sharedraw/config.xml (original)
+++ incubator/wookie/trunk/widgets/sharedraw/config.xml Fri Mar 16 12:29:42 2012
@@ -17,8 +17,8 @@
<widget xmlns="http://www.w3.org/ns/widgets"
id="http://wookie.apache.org/widgets/sharedraw"
version="0.1"
- width="420"
- height="320"
+ width="400"
+ height="300"
>
<feature name="http://wave.google.com" required="true"/>
<name>ShareDraw</name>
Modified: incubator/wookie/trunk/widgets/sharedraw/index.html
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/sharedraw/index.html?rev=1301461&r1=1301460&r2=1301461&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/sharedraw/index.html (original)
+++ incubator/wookie/trunk/widgets/sharedraw/index.html Fri Mar 16 12:29:42 2012
@@ -20,16 +20,15 @@
<meta charset="utf-8">
<title>Paint</title>
<style type="text/css"><!--
- #container { position: relative; }
- #imageView { border: 1px solid #000; cursor: crosshair }
+ html,body,div, canvas {margin:0px; padding:0px; overflow:hidden}
+ #imageView { border: none; cursor: crosshair }
--></style>
<!--[if lt IE 9]><script type="text/javascript" src="scripts/flashcanvas.js"></script><![endif]-->
<script type="text/javascript" src="scripts/sharedraw.js"></script>
<script type="text/javascript" src="scripts/draw.js"></script>
</head>
<body onload="Controller.init()">
- <div id="container">
- <canvas id="imageView" width="400" height="300">
+ <canvas id="imageView" height="300" width="400">
<p>Unfortunately, your browser is currently unsupported by this widget.
We are sorry for the inconvenience. Please use one of the
supported browsers listed below:</p>
@@ -38,6 +37,5 @@
href="http://www.apple.com/safari">Safari</a>, and <a
href="http://www.konqueror.org">Konqueror</a>.</p>
</canvas>
- </div>
</body>
</html>
\ No newline at end of file
Modified: incubator/wookie/trunk/widgets/sharedraw/scripts/draw.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/sharedraw/scripts/draw.js?rev=1301461&r1=1301460&r2=1301461&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/sharedraw/scripts/draw.js (original)
+++ incubator/wookie/trunk/widgets/sharedraw/scripts/draw.js Fri Mar 16 12:29:42 2012
@@ -37,6 +37,11 @@ function init_canvas () {
alert('Error: failed to getContext!');
return;
}
+
+ // Fit canvas to window
+ var viewport = getViewport();
+ context.canvas.width = viewport.width;
+ context.canvas.height = viewport.height;
// Pencil tool instance.
tool = new tool_pencil();
@@ -95,3 +100,26 @@ function init_canvas () {
func(ev);
}
}
+
+ //
+ // Get the viewport height and width
+ //
+ function getViewport() {
+ var viewport = {};
+ viewport.height = 0;
+ viewport.width = 0;
+ if( typeof( window.innerHeight ) == 'number' ) {
+ //Non-IE
+ viewport.height = window.innerHeight;
+ viewport.width = window.innerWidth;
+ } else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ //IE 6+ in 'standards compliant mode'
+ viewport.height = document.documentElement.clientHeight;
+ viewport.width = document.documentElement.clientWidth;
+ } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
+ //IE 4 compatible
+ viewport.height = document.body.clientHeight;
+ viewport.width = document.body.clientWidth;
+ }
+ return viewport;
+ }