forked from alefeuvre/foundation-grid-displayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gd-bookmarklet.min.js
1 lines (1 loc) · 6.11 KB
/
gd-bookmarklet.min.js
1
(function(){var a=function(k){var u=k("script[src*='gd-bookmarklet.min.js']").attr("src"),g=u.substr(u.length-1,1);if(g!="b"&&g!="f"){g="both"}var w=function(){k("#grid-displayer-tools").remove();k("#grid-displayer").remove()},o=false,A=function(J){var D=k("#grid-displayer .gd-container"),K=k("#grid-displayer .gd-row"),G=k("#grid-displayer-tools"),E="",C=parseInt(G.find("#gdt-nbcols").val());if(o){D.removeClass().addClass("gd-container");K.removeClass().addClass("gd-row").css("border-right",0).empty();G.find(".framework-specific").hide()}for(var F=0;F<C;F++){E+='<div class="gd-column"> </div>'}K.append(E);var H=K.find(".gd-column"),I=false,B=false;switch(J){case"b3":D.addClass("container");K.addClass("row");H.addClass("col-xs-1");I=true,B=true;break;case"b3f":D.addClass("container-fluid");K.addClass("row");H.addClass("col-xs-1");I=true,B=true;break;case"bo":D.addClass("container");K.addClass("row");H.addClass("span1");B=true;break;case"bf":D.addClass("container-fluid");K.addClass("row-fluid");H.addClass("span1");B=true;break;case"f4":D.addClass("container");K.addClass("row");H.addClass("small-1 columns");I=true;break;case"f3":D.addClass("container");K.addClass("row");H.addClass("one columns");I=true;break;case"f2":D.addClass("container");K.addClass("row");H.addClass("one columns");break}if(I){G.find(".gutterless").css("display","inline-block");z(G.find("#gdt-gutterwidth").val())}else{H.css({border:"0"})}if(B){G.find(".twb").css("display","inline-block")}s(G.find("#gdt-color").val(),I);l(G.find("#gdt-opacity").val());if(!o){G.find("#gdt-options").css("display","block");G.find("#gdt-ok").css("display","block");r(G.find("#gdt-zindex").val());k("#grid-displayer").show();o=true}},s=function(B,C){k("#grid-displayer .gd-column").css("background-color",B);if(C){k("#grid-displayer .gd-column").css("outline","1px solid "+B)}},l=function(B){k("#grid-displayer .gd-column").css("opacity",B)},z=function(C){var B=parseInt(C.replace(/^\D+/g,""))/2,D=C.substr(C.length-2,2);k("#grid-displayer .gd-column").css({"border-width":"0 "+B+D,"border-style":"solid","border-color":"#FFF",padding:0})},r=function(B){k("#grid-displayer").css("z-index",B)};if(k("#grid-displayer").length){w()}else{var e=k("body").data("grid-framework"),i=k("body").data("grid-nbcols"),y=k("body").data("grid-gutterwidth"),v=k("body").data("grid-color"),d=k("body").data("grid-opacity"),f=k("body").data("grid-zindex"),x=(typeof e==="undefined")?"":e,n=(typeof i==="undefined")?"12":i,h=(typeof y==="undefined")?"30px":y,q=(typeof v==="undefined")?"black":v,t=(typeof d==="undefined")?"0.3":d,j=(typeof f==="undefined")?"999":f;bootstraps=[["b3","Bootstrap 3"],["b3f","Bootstrap 3 (fluid)"],["bo","Bootstrap 2"],["bf","Bootstrap 2 (fluid)"]],foundations=[["f4","Foundation 4 & 5"],["f3","Foundation 3"],["f2","Foundation 2"]];switch(g){case"b":frameworks=bootstraps;if(x==""){x="b3"}break;case"f":frameworks=foundations;if(x==""){x="f4"}break;case"both":frameworks=bootstraps.concat(foundations);break}var m='<div id="grid-displayer" style="display: none;"><div class="gd-container"><div class="gd-row"></div></div></div>',p='<div id="grid-displayer-tools"> <div class="gdt-field"><select id="gdt-framework"> <option>↓ Choose your framework</option>';k.each(frameworks,function(B,C){p+='<option value="'+C[0]+'"';p+=(C[0]==x)?" selected":"";p+=">"+C[1]+"</option>"});p+=' <option value="tired">I\'m tired of choosing my framework</option> </select></div> <div id="gdt-options" class="gdt-field"> <div><label for="gdt-color">Columns colour</label><input type="text" id="gdt-color" value="'+q+'" /></div><div><label for="gdt-opacity">Opacity</label><input type="text" id="gdt-opacity" value="'+t+'" /></div><div class="framework-specific gutterless"><label for="gdt-gutterwidth">Gutter width</label><input type="text" id="gdt-gutterwidth" value="'+h+'" /></div><div class="framework-specific twb"><label for="gdt-nbcols">Nb cols</label><input type="text" id="gdt-nbcols" value="'+n+'" /></div><div><label for="gdt-zindex">z-index</label><input type="text" id="gdt-zindex" value="'+j+'" /></div> </div> <div class="gdt-button" id="gdt-ok"><a href="javascript:;">OK</a></div> <div class="gdt-button"><a href="#null" id="gdt-close">Close</a></div></div>';k("head").append("<link rel='stylesheet' type='text/css' href='http://alefeuvre.github.com/foundation-grid-displayer/stylesheets/gd-bookmarklet.min.css'>");k("body").prepend(m).prepend(p);k("#grid-displayer-tools").delay(1200).fadeTo("slow",0.1);if(x!=""){A(x)}k("#grid-displayer-tools #gdt-framework").change(function(){if(k(this).val()=="tired"){window.open("http://snipt.net/jiraisurfer/custom-parameters-for-foundation-grid-displayer/")}else{x=k(this).val();gdIsGutterless=(x=="b3"||x=="b3f"||x=="f4"||x=="f3")?true:false;if(x=="f4"||x=="f3"||x=="f2"){k("#grid-displayer-tools #gdt-nbcols").val(12)}A(x)}});k("#grid-displayer-tools #gdt-nbcols").change(function(){A(x)});k("#grid-displayer-tools #gdt-color").change(function(){s(k(this).val(),gdIsGutterless)});k("#grid-displayer-tools #gdt-opacity").change(function(){l(k(this).val())});k("#grid-displayer-tools #gdt-gutterwidth").change(function(){z(k(this).val())});k("#grid-displayer-tools #gdt-zindex").change(function(){r(k(this).val())});k("#grid-displayer-tools #gdt-close").click(function(){w()})}};if(!window.jQuery){var b=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript";c.src="http://code.jquery.com/jquery-1.10.0.min.js";c.onload=function(){a(window.jQuery)};b.appendChild(c)}else{a(window.jQuery)}(function(h,j,e){function o(q,i){return q+Math.floor(Math.random()*(i-q))}var l=1000000000,p=o(l,9999999999),f=o(10000000,99999999),g=o(l,2147483647),n=(new Date()).getTime(),m=window.location,k=new Image(),d="http://www.google-analytics.com/__utm.gif?utmwv=1.3&utmn="+p+"&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn="+j+"&utmr="+m+"&utmp="+e+"&utmac="+h+"&utmcc=__utma%3D"+f+"."+g+"."+n+"."+n+"."+n+".2%3B%2B__utmb%3D"+f+"%3B%2B__utmc%3D"+f+"%3B%2B__utmz%3D"+f+"."+n+".2.2.utmccn%3D(referral)%7Cutmcsr%3D"+m.host+"%7Cutmcct%3D"+m.pathname+"%7Cutmcmd%3Dreferral%3B%2B__utmv%3D"+f+".-%3B";k.src=d})("UA-30567117-1","alefeuvre.github.io","gd-bookmarklet.js")})();