You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
|
1 month ago
|
/*! rulez.js 2019-09-18 */
|
||
|
|
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("rulez.js requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=function(b){"use strict";function c(b){var d,e=b.cloneNode(!1);if(b instanceof Element){var f=a.getComputedStyle(b);if(f)for(d=0;d<f.length;d++){var g=f[d];e.style.setProperty(g,f.getPropertyValue(g),"")}}for(d=0;d<b.childNodes.length;d++)e.appendChild(c(b.childNodes[d]));return e}function d(){R||G.divisions.forEach(function(a){a.pixelGap>R&&(R=a.pixelGap)}),I=J-J%R+R*L,H=-R*L}function e(a,b){G.divisions.forEach(function(c){f(a,b,c)});var c=0;G.texts.forEach(function(d){var e=m(a,b,d);N[c]?N[c]=N[c].concat(e):N.push(e),c++})}function f(a,b,c){for(var d=a;d<b;d+=c.pixelGap){var e=n(d,c);M.appendChild(e),c.renderer&&c.renderer(e)}}function g(){G.guides.forEach(function(a){h(a)})}function h(a){var b=l(a);O.push(b),j(b,a),M.appendChild(b),a.renderer&&a.renderer(b)}function i(a,b){var c=-P%(R*K),d=b.position/Q-P-c;a.setAttribute("transform",v()?"translate(0,"+d+")":"translate("+d+",0)")}function j(a,b){var c,d=b.position,e=v(),f=e?"pageY":"pageX",g=e?"rulez-guide-vert-global":"rulez-guide-horiz-global",h=e?"Y : ":"X : ",j=e?10:0,l=e?0:10,m=document.createElement("span");m.classList.add("rulez-position-element");var n=function(a){m.innerText=h+b.position,m.style.left=a.pageX+j+"px",m.style.top=a.pageY+l+"px"},o=function(e){e.preventDefault();var g=e[f],h=c-g;if(b.position=d-h*Q,e.shiftKey){var j=G.guideSnapInterval/2,k=b.position%G.guideSnapInterval,l=Math.abs(k),m=k;l>j?(m=Math.sign(k)*(G.guideSnapInterval-l),b.position=Math.round(b.position+m)):b.position=Math.round(b.position-m)}else b.position=Math.round(b.position);n(e),i(a,b)},p=function(a){document.body.classList.remove(g),document.body.removeChild(m),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",p)};a.addEventListener("mousedown",function(a){a.stopPropagation(),document.body.classList.add(g),c=a[f],d=b.position,n(a),document.body.appendChild(m),document.addEventListener("mouseup",p),document.addEventListener("mousemove",o)},!0),a.addEventListener("dblclick",function(){k(a,b)})}function k(a,b){O=O.filter(function(b){return b!==a}),G.guides=G.guides.filter(function(a){return a!==b}),a.parentNode.removeChild(a)}function l(a){return o(a)}function m(a,b,c){for(var d=[],e=a;e<b;e+=c.pixelGap){var f=t(e,c);M.appendChild(f),c.renderer&&c.renderer(f),d.push(f)}return d}function n(a,b){switch(b.type){case"line":return p(a,b);case"rect":default:return q(a,b)}}function o(a){var b=s(0,a.className,a.getSize(a),a.strokeWidth,0);return i(b,a),b}function p(a,b){return r(a,b.className,b.lineLength,b.strokeWidth)}function q(a,b){return s(a,b.className,b.lineLength,b.strokeWidth)}function r(b,c,d,e){var f,g,h,i,j=a.document.createElementNS(D,"line"),k=w();return v()?(f="y1",g="y2",h="x1",i="x2"):(f="x1",g="x2",h="y1",i="y2"),j.setAttribute("class",c),j.setAttribute(f,z(b)),j.setAttribute(g,z(b)),j.setAttribute(h,z(k?"0":x()-d)),j.setAttribute(i,z(k?d:x())),j.setAttribute("stroke-width",z(e)),j}function s(b,c,d,e,f){var g,h,i,j,k=a.document.createElementNS(D,"rect"),l=w();v()?(g="y",h="x",i="width",j="height"):(g="x",h="y",i="height",j="width");var m=void 0!==f?f:l?"0":x()-d;return k.setAttribute("class",c),k.setAttribute(g,z(b)),k.setAttribute(h,z(m)),k.setAttribute(i,z(d)),k.setAttribute(j,z(e)),k}function t(b,c){var d,e,f=a.document.createElementNS(D,"text"),g=C(c);return f.setAttribute("class",c.className),v()?(d="y",e="x"):(d="x",e="y"),f.origPos=b,f.origPosAttribute=d,f.setAttribute(d,z(b)),f.setAttribute(e,z(g)),B(f,c),f.textContent=c.showUnits?z(b):b,c.centerText&&f.setAttribute("text-anchor","middle"),f}function u(){return a.document.createElementNS(D,"g")}function v(){return"vertical"===G.layout}function w(){return!("bottom"===G.alignment||"right"===G.alignment)}function x(){return v()?G.width:G.height}function y(a,b,c){if(!b)return a;for(var d in b)if(b.hasOwnProperty(d))sw
|