Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

44 строки
1.3KB

  1. /*
  2. * OrientationController.js
  3. * Keynote HTML Player
  4. *
  5. * Responsibility: Tungwei Cheng
  6. * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
  7. */
  8. var kOrientationChangedEvent = "OrientationController:OrientationChangedEvent";
  9. var OrientationController = Class.create({
  10. initialize: function() {
  11. var platform = navigator.platform;
  12. // observe orientationchange event
  13. if (platform === "iPad" || platform === "iPhone" || platform === "iPod") {
  14. Event.observe(window, "orientationchange", this.handleDeviceOrientationChangeEvent.bind(this));
  15. this.handleDeviceOrientationChangeEvent();
  16. }
  17. this.orientation = kOrientationUnknown;
  18. },
  19. handleDeviceOrientationChangeEvent: function(event) {
  20. var orientationInDegrees = window.orientation;
  21. var newOrientation = kOrientationUnknown;
  22. if ((orientationInDegrees === 90) || (orientationInDegrees === -90)) {
  23. newOrientation = kOrientationLandscape;
  24. } else {
  25. newOrientation = kOrientationPortrait;
  26. }
  27. this.changeOrientation(newOrientation);
  28. },
  29. changeOrientation: function(newOrientation) {
  30. this.orientation = newOrientation;
  31. document.fire(kOrientationChangedEvent, {
  32. orientation: this.orientation
  33. });
  34. }
  35. });