-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewtoggle.min.js
2 lines (2 loc) · 996 Bytes
/
viewtoggle.min.js
1
2
/* ViewToggle v.0.2 (c) 2012: Sean Ockert, http://seanockert.github.com/ViewToggle */
ViewToggle=function(e){var t=document.getElementById("viewtoggle");document.all&&!document.querySelector&&t.parentNode.removeChild(t);var n={},r=t.innerHTML,i="View mobile site",s=!1,o=980,u="device-width",a=document.querySelector("meta[name=viewport]"),f=!0;return n={load:function(){localStorage.isResponsive=localStorage.isResponsive===undefined?"true":localStorage.isResponsive,localStorage.isResponsive==="false"&&n.showFull(),document.addEventListener?t.addEventListener("click",n.toggle,!0):t.attachEvent&&t.attachEvent("onclick",n.toggle)},toggle:function(e){return e.preventDefault(),f===!0?n.showFull():n.showMobile(),s==1&&document.location.reload(!0),!1},showFull:function(){a.setAttribute("content","width="+o),f=!1,localStorage.isResponsive="false",t.innerHTML=i},showMobile:function(){a.setAttribute("content","width="+u),f=!0,localStorage.isResponsive="true",t.innerHTML=r}},n.load(),n}(window)