-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid.min.js
9 lines (9 loc) · 2.03 KB
/
grid.min.js
1
2
3
4
5
6
7
8
9
/*
*
* Made by Zach Wolf
* http://www.zachwolf.com
* @hellozachwolf
*
* Documentation http://grids.ee
*
*/(function(){$.fn.gridsee=function(a){var b=$("script"),c={},d=$(this);$.each(b,function(a,b){var d=$(b),e=d.attr("src");if(e!=undefined){if(e.indexOf("grids.ee")!=-1){var f=e.split("?")[1];if(f==undefined)return;f=e.split("?")[1].split("&");$.each(f,function(a,b){$temp=b.split("=");c[$temp[0]]=$temp[1]})}}});grid={lineHeight:a.lineheight||c.lineheight||20,keyCode:a.keyCodes||c.keyCodes||["91","186"],keysDown:new Array,target:d||$(window),isShown:false,init:function(a){var b=this;if($.isArray(this.keyCode)==false){$strings=this.keyCode.split(",");b.keyCode=[];$.each($strings,function(a,c){b.keyCode.push(parseInt(c))})}this.keyCode=this.keyCode.sort(function(a,b){return a-b});this.keyListener(d,this.keyCode);this.gridEl=$("<div></div>",{"class":"quick-grid",css:{position:"absolute",top:0,left:0,right:0,height:$(document).height(),background:"url('http://grids.ee/make/lines/"+b.lineHeight+".png')",zIndex:1337}}).prependTo("body").hide();if($("html").hasClass("touch")==true){$(window).on("touchstart",function(){return true});var c="http://grids.ee/img/gridsee-logo.png";if(window.devicePixelRatio>1){c="http://grids.ee/img/[email protected]"}$("<a></a>",{"class":"gridsee-toggle",css:{position:"absolute",top:0,right:20,height:0,width:50,background:"url("+c+") center bottom","background-size":"100%",zIndex:8675309}}).on("touchstart",function(a){b.toggleGrid()}).animate({height:53},500).prependTo("body")}},keyListener:function(a,b){var c=this;a.on("keydown",function(a){if($.inArray(a.keyCode,c.keysDown)==-1){c.keysDown.push(a.keyCode)}c.keysDown=c.keysDown.sort(function(a,b){return a-b});if(c.compare(c.keyCode,c.keysDown)==true){c.toggleGrid()}}).on("keyup",function(a){c.keysDown=[]})},compare:function(a,b){for(var c=a.length-1;c>=0;c--){if(a[c]!=b[c])return;return true}},toggleGrid:function(){var a=this;if(a.isShown==true){a.gridEl.hide();a.isShown=false}else{a.gridEl.show();a.isShown=true}}};grid.init();return this}})(jQuery)