您最多选择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. });