qp.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //全屏
  2. (function (a, b) {
  3. "use strict";
  4. var c = function () {
  5. var a = [["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreen", "fullscreenElement"], ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"], ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement"]];
  6. for (var c = 0,
  7. d = a.length; c < d; c++) {
  8. var e = a[c];
  9. if (e[1] in b) return e
  10. }
  11. } ();
  12. if (!c) return a.screenfull = !1;
  13. var d = "ALLOW_KEYBOARD_INPUT" in Element,
  14. e = {
  15. init: function () {
  16. return b.addEventListener(c[2],
  17. function (a) {
  18. e.isFullscreen = b[c[3]],
  19. e.element = b[c[4]],
  20. e.onchange(a)
  21. }),
  22. this
  23. },
  24. isFullscreen: b[c[3]],
  25. element: b[c[4]],
  26. request: function (a) {
  27. a = a || b.documentElement,
  28. a[c[0]](d && Element.ALLOW_KEYBOARD_INPUT),
  29. b.isFullscreen || a[c[0]]();
  30. //alert("dd");
  31. },
  32. exit: function () {
  33. b[c[1]]()
  34. },
  35. toggle: function (a) {
  36. this.isFullscreen ? this.exit() : this.request(a)
  37. },
  38. onchange: function () { }
  39. };
  40. a.screenfull = e.init()
  41. })(window, document)