[OpenLayers-Commits] r11320 - in sandbox/sbrunner/openlayers: examples lib/OpenLayers/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 23 09:00:19 EST 2011


Author: fredj
Date: 2011-02-23 06:00:19 -0800 (Wed, 23 Feb 2011)
New Revision: 11320

Modified:
   sandbox/sbrunner/openlayers/examples/orientation.html
   sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js
Log:
call supported function, add docs

Modified: sandbox/sbrunner/openlayers/examples/orientation.html
===================================================================
--- sandbox/sbrunner/openlayers/examples/orientation.html	2011-02-23 14:00:08 UTC (rev 11319)
+++ sandbox/sbrunner/openlayers/examples/orientation.html	2011-02-23 14:00:19 UTC (rev 11320)
@@ -18,7 +18,7 @@
     function init() {
         var logs = document.getElementById("logs");
         orientation = new OpenLayers.Control.DeviceOrientation();
-        if (orientation.supported) {
+        if (orientation.supported()) {
             orientation.events.register("orientationchange", this, function(event) {
                 var img = document.getElementById("orientation");
                 var value = "rotate(" + event.orientation + "deg)";

Modified: sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js
===================================================================
--- sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js	2011-02-23 14:00:08 UTC (rev 11319)
+++ sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js	2011-02-23 14:00:19 UTC (rev 11320)
@@ -3,21 +3,46 @@
  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
  * full text of the license. */
 
+/**
+ * @requires OpenLayers/Control.js
+ */
 
 /**
  * Class: OpenLayers.Control.DeviceOrientation
  * see: http://dev.w3.org/geo/api/spec-source-orientation.html
  */
-
 OpenLayers.Control.DeviceOrientation = OpenLayers.Class(OpenLayers.Control, {
 
+    /**
+     * Constant: EVENT_TYPES
+     */
     EVENT_TYPES: ["orientationchange"],
 
     /**
      * Property: last
+     * {Event}
      */
     last: null,
 
+    /**
+     * Constructor: OpenLayers.Control.DeviceOrientation
+     * Create a new control to deal with device orientation
+     */
+    initialize: function(options) {
+        // concatenate events specific to this control with those from the base
+        this.EVENT_TYPES =
+            OpenLayers.Control.DeviceOrientation.prototype.EVENT_TYPES.concat(
+            OpenLayers.Control.prototype.EVENT_TYPES
+        );
+        OpenLayers.Control.prototype.initialize.apply(this, [options]);
+    },
+
+    /**
+     * APIMethod: supported
+     * 
+     * Returns:
+     * {Boolean} Whether or not the browser supports device orientation
+     */
     supported: function() {
         return !!(window.DeviceOrientationEvent);
     },



More information about the Commits mailing list