-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathstretchy.min.js.map
1 lines (1 loc) · 10 KB
/
stretchy.min.js.map
1
{"version":3,"sources":["stretchy.js"],"names":["self","Element","prototype","matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","_","Stretchy","selectors","base","split","join","filter","script","document","currentScript","$$","pop","resize","element","resizes","empty","cs","getComputedStyle","offset","value","placeholder","type","nodeName","toLowerCase","style","height","boxSizing","offsetHeight","clientHeight","parseFloat","minHeight","scrollHeight","width","offsetWidth","clientWidth","minWidth","Math","max","scrollWidth","i","scrollLeft","length","selectedIndex","appearance","option","createElement","property","textContent","options","parentNode","insertBefore","nextSibling","test","removeChild","resizeAll","elements","forEach","active","init","getAttribute","body","MutationObserver","observer","mutations","mutation","addedNodes","observe","documentElement","childList","subtree","readyState","requestAnimationFrame","addEventListener","window","listener","evt","target","expr","con","Node","Window","slice","call","querySelectorAll"],"mappings":"CAKA,WAEA,GAAKA,KAAKC,UAILA,QAAQC,UAAUC,UACtBF,QAAQC,UAAUC,QAAUF,QAAQC,UAAUE,uBAAyBH,QAAQC,UAAUG,oBAAsBJ,QAAQC,UAAUI,mBAAqBL,QAAQC,UAAUK,kBAAoB,MAGxLN,QAAQC,UAAUC,SAAvB,CASA,IAAIK,EAAIR,KAAKS,SAAW,CACvBC,UAAW,CACVC,KAAM,gEAAkE,4BAA4BC,MAAM,KAAKC,KAAK,oBAAsB,KAC1IC,OAAQ,KAITC,OAAQC,SAASC,eAAiBC,EAAG,UAAUC,MAG/CC,OAAQ,SAASC,GAChB,GAAKb,EAAEc,QAAQD,GAAf,CAIA,IAEIE,EAFAC,EAAKC,iBAAiBJ,GACtBK,EAAS,GAGRL,EAAQM,OAASN,EAAQO,cAC7BL,GAAQ,EACRF,EAAQM,MAAQN,EAAQO,aAGzB,IAAIC,EAAOR,EAAQS,SAASC,cAE5B,GAAY,YAARF,EACHR,EAAQW,MAAMC,OAAS,IAEH,cAAhBT,EAAGU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E,MAAQF,aAAgBG,OAAQ,CAACH,GACjD,GAAGI,MAAMC,KAAoB,iBAARL,GAAmBC,GAAOtE,UAAU2E,iBAAiBN,GAAQA,GAAQ;EAhBlG","file":"stretchy.min.js","sourcesContent":["/*\n * Stretchy: Form element autosizing, the way it should be.\n * by Lea Verou http://lea.verou.me\n * MIT license\n */\n(function() {\n\nif (!self.Element) {\n\treturn; // super old browser\n}\n\nif (!Element.prototype.matches) {\n\tElement.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || null;\n}\n\nif (!Element.prototype.matches) {\n\treturn;\n}\n\nfunction $$(expr, con) {\n\treturn expr instanceof Node || expr instanceof Window? [expr] :\n\t [].slice.call(typeof expr == \"string\"? (con || document).querySelectorAll(expr) : expr || []);\n}\n\nvar _ = self.Stretchy = {\n\tselectors: {\n\t\tbase: 'textarea, select:not([size]), input:not([type]), input[type=\"' + \"text number url email tel\".split(\" \").join('\"], input[type=\"') + '\"]',\n\t\tfilter: \"*\"\n\t},\n\n\t// Script element this was included with, if any\n\tscript: document.currentScript || $$(\"script\").pop(),\n\n\t// Autosize one element. The core of Stretchy.\n\tresize: function(element) {\n\t\tif (!_.resizes(element)) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar cs = getComputedStyle(element);\n\t\tvar offset = 0;\n\t\tvar empty;\n\n\t\tif (!element.value && element.placeholder) {\n\t\t\tempty = true;\n\t\t\telement.value = element.placeholder;\n\t\t}\n\n\t\tvar type = element.nodeName.toLowerCase();\n\n\t\tif (type == \"textarea\") {\n\t\t\telement.style.height = \"0\";\n\n\t\t\tif (cs.boxSizing == \"border-box\") {\n\t\t\t\toffset = element.offsetHeight;\n\t\t\t}\n\t\t\telse if (cs.boxSizing == \"content-box\") {\n\t\t\t\toffset = -element.clientHeight + parseFloat(cs.minHeight);\n\t\t\t}\n\n\t\t\telement.style.height = element.scrollHeight + offset + \"px\";\n\t\t}\n\t\telse if (type == \"input\") {\n\t\t\t// First test that it is actually visible, otherwise all measurements are off\n\t\t\telement.style.width = \"1000px\";\n\n\t\t\tif (element.offsetWidth) {\n\t\t\t\telement.style.width = \"0\";\n\n\t\t\t\tif (cs.boxSizing == \"border-box\") {\n\t\t\t\t\toffset = element.offsetWidth;\n\t\t\t\t}\n\t\t\t\telse if (cs.boxSizing == \"padding-box\") {\n\t\t\t\t\toffset = element.clientWidth;\n\t\t\t\t}\n\t\t\t\telse if (cs.boxSizing == \"content-box\") {\n\t\t\t\t\toffset = parseFloat(cs.minWidth);\n\t\t\t\t}\n\n\t\t\t\tvar width = Math.max(offset, element.scrollWidth - element.clientWidth);\n\n\t\t\t\telement.style.width = width + \"px\";\n\n\t\t\t\t// To bulletproof, we will set scrollLeft to a\n\t\t\t\t// huge number, and read that back to see what it was clipped to\n\t\t\t\t// and increment width by that much, iteratively\n\n\t\t\t\tfor (var i=0; i<10; i++) { // max iterations\n\t\t\t\t\telement.scrollLeft = 1e+10;\n\n\t\t\t\t\tif (element.scrollLeft == 0) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\twidth += element.scrollLeft;\n\n\t\t\t\t\telement.style.width = width + \"px\";\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Element is invisible, just set to something reasonable\n\t\t\t\telement.style.width = element.value.length + 1 + \"ch\";\n\t\t\t}\n\t\t}\n\t\telse if (type == \"select\") {\n\n\t\t\t//if select element is empty, do nothing\n\t\t\tif (element.selectedIndex == -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar selectedIndex = element.selectedIndex > 0? element.selectedIndex : 0;\n\n\t\t\t// Need to use dummy element to measure :(\n\t\t\tvar option = document.createElement(\"_\");\n\t\t\toption.textContent = element.options[selectedIndex].textContent;\n\t\t\telement.parentNode.insertBefore(option, element.nextSibling);\n\n\t\t\t// The name of the appearance property, as it might be prefixed\n\t\t\tvar appearance;\n\n\t\t\tfor (var property in cs) {\n\t\t\t\tvar value = cs[property];\n\t\t\t\tif (!/^(width|webkitLogicalWidth|length)$/.test(property) && typeof value == \"string\") {\n\t\t\t\t\toption.style[property] = value;\n\n\t\t\t\t\tif (/appearance$/i.test(property)) {\n\t\t\t\t\t\tappearance = property;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toption.style.width = \"\";\n\n\t\t\tif (option.offsetWidth > 0) {\n\t\t\t\telement.style.width = option.offsetWidth + \"px\";\n\n\t\t\t\tif (!cs[appearance] || cs[appearance] !== \"none\") {\n\t\t\t\t\t// Account for arrow\n\t\t\t\t\telement.style.width = \"calc(\" + element.style.width + \" + 2em)\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toption.parentNode.removeChild(option);\n\t\t\toption = null;\n\t\t}\n\n\t\tif (empty) {\n\t\t\telement.value = \"\";\n\t\t}\n\t},\n\n\t// Autosize multiple elements\n\tresizeAll: function(elements) {\n\t\t$$(elements || _.selectors.base).forEach(function (element) {\n\t\t\t_.resize(element);\n\t\t});\n\t},\n\n\tactive: true,\n\n\t// Will stretchy do anything for this element?\n\tresizes: function(element) {\n\t\treturn element &&\n\t\t element.parentNode &&\n\t\t element.matches &&\n\t\t element.matches(_.selectors.base) &&\n\t\t element.matches(_.selectors.filter);\n\t},\n\n\tinit: function(){\n\t\t_.selectors.filter = _.script.getAttribute(\"data-filter\") ||\n\t\t ($$(\"[data-stretchy-filter]\").pop() || document.body).getAttribute(\"data-stretchy-filter\") || _.selectors.filter;\n\n\t\t_.resizeAll();\n\n\t\t// Listen for new elements\n\t\tif (self.MutationObserver && !_.observer) {\n\t\t\t_.observer = new MutationObserver(function(mutations) {\n\t\t\t\tif (_.active) {\n\t\t\t\t\tmutations.forEach(function(mutation) {\n\t\t\t\t\t\tif (mutation.type == \"childList\") {\n\t\t\t\t\t\t\t_.resizeAll(mutation.addedNodes);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t\t_.observer.observe(document.documentElement, {\n\t\t\t\tchildList: true,\n\t\t\t\tsubtree: true\n\t\t\t});\n\t\t}\n\t},\n\n\t$$: $$\n};\n\n// Autosize all elements once the DOM is loaded\n\n// DOM already loaded?\nif (document.readyState !== \"loading\") {\n\trequestAnimationFrame(_.init);\n}\nelse {\n\t// Wait for it\n\tdocument.addEventListener(\"DOMContentLoaded\", _.init);\n}\n\nwindow.addEventListener(\"load\", function(){\n\t_.resizeAll();\n});\n\n// Listen for changes\nvar listener = function(evt) {\n\tif (_.active) {\n\t\t_.resize(evt.target);\n\t}\n};\n\ndocument.documentElement.addEventListener(\"input\", listener);\n\n// Firefox fires a change event instead of an input event\ndocument.documentElement.addEventListener(\"change\", listener);\n\n})();\n"]}