-
Notifications
You must be signed in to change notification settings - Fork 1
/
orientationchange.min.js
1 lines (1 loc) · 1.26 KB
/
orientationchange.min.js
1
(function(a){"use strict";var b,c,d,e,f,g,h,i,j;e=false;a.event.special.orientationchange={setup:function(){var f=document.createElement("div");if(window.hasOwnProperty("orientation")){return false}c=document.createElement("style");c.setAttribute("type","text/css");c.setAttribute("media","screen");document.getElementsByTagName("head")[0].appendChild(c);c.appendChild(document.createTextNode("@media screen and (orientation:portrait) { #orientation-check{ visibility: hidden; display: inline; }}@media screen and (orientation:landscape) {#orientation-check{ visibility: visible; display: inline;}}"));a("body").append('<div id="orientation-check"></div>');d=a("#orientation-check");g=d.css("display")==="inline"?true:false;b=[];e=i();h();a(window).bind("resize",function(a){b.push(i())})},add:function(a){var b=a.handler;a.handler=function(a){if(e!==false){window.orientation=e}b.apply(this,arguments)}},teardown:function(){if(e===false){return false}d.remove();window.unbind("resize");j()}};j=function(){clearTimeout(f)};i=function(){var b;if(g){b=d.css("visibility")==="visible"?90:0;return b}b=Math.floor(a(window).width()/a(window).height())>1?90:0;return b};h=function(){j();if(b.length>0){if(e!==b[0]){e=b[0];a(window).trigger("orientationchange")}b=[]}f=setTimeout(h,50)}})(jQuery)