No Description

viewport.js 839B

12345678910111213141516171819202122232425262728293031
  1. (function () {
  2. var DEFAULT_VIEWPORT = 'width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no';
  3. var Viewport = {
  4. ensureViewportElement: function ensureViewportElement() {
  5. var viewportElement = document.querySelector('meta[name=viewport]');
  6. if (!viewportElement) {
  7. viewportElement = document.createElement('meta');
  8. viewportElement.name = 'viewport';
  9. document.head.appendChild(viewportElement);
  10. }
  11. return viewportElement;
  12. },
  13. setup: function setup() {
  14. var viewportElement = Viewport.ensureViewportElement();
  15. if (!viewportElement) {
  16. return;
  17. }
  18. if (!viewportElement.hasAttribute('content')) {
  19. viewportElement.setAttribute('content', DEFAULT_VIEWPORT);
  20. }
  21. }
  22. };
  23. window.Viewport = Viewport;
  24. })();