{"version":3,"file":"ext-textarea-d1b04621.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-textarea.js"],"sourcesContent":["ace.define(\"ace/ext/textarea\",[\"require\",\"exports\",\"module\",\"ace/lib/event\",\"ace/lib/useragent\",\"ace/ace\"], function(require, exports, module){\"use strict\";\nvar event = require(\"../lib/event\");\nvar UA = require(\"../lib/useragent\");\nvar ace = require(\"../ace\");\nmodule.exports = exports = ace;\nvar getCSSProperty = function (element, container, property) {\n var ret = element.style[property];\n if (!ret) {\n if (window.getComputedStyle) {\n ret = window.getComputedStyle(element, '').getPropertyValue(property);\n }\n else {\n ret = element.currentStyle[property];\n }\n }\n if (!ret || ret == 'auto' || ret == 'intrinsic') {\n ret = container.style[property];\n }\n return ret;\n};\nfunction applyStyles(elm, styles) {\n for (var style in styles) {\n elm.style[style] = styles[style];\n }\n}\nfunction setupContainer(element, getValue) {\n if (element.type != 'textarea') {\n throw new Error(\"Textarea required!\");\n }\n var parentNode = element.parentNode;\n var container = document.createElement('div');\n var resizeEvent = function () {\n var style = 'position:relative;';\n [\n 'margin-top', 'margin-left', 'margin-right', 'margin-bottom'\n ].forEach(function (item) {\n style += item + ':' +\n getCSSProperty(element, container, item) + ';';\n });\n var width = getCSSProperty(element, container, 'width') || (element.clientWidth + \"px\");\n var height = getCSSProperty(element, container, 'height') || (element.clientHeight + \"px\");\n style += 'height:' + height + ';width:' + width + ';';\n style += 'display:inline-block;';\n container.setAttribute('style', style);\n };\n event.addListener(window, 'resize', resizeEvent);\n resizeEvent();\n parentNode.insertBefore(container, element.nextSibling);\n while (parentNode !== document) {\n if (parentNode.tagName.toUpperCase() === 'FORM') {\n var oldSumit = parentNode.onsubmit;\n parentNode.onsubmit = function (evt) {\n element.value = getValue();\n if (oldSumit) {\n oldSumit.call(this, evt);\n }\n };\n break;\n }\n parentNode = parentNode.parentNode;\n }\n return container;\n}\nexports.transformTextarea = function (element, options) {\n var isFocused = element.autofocus || document.activeElement == element;\n var session;\n var container = setupContainer(element, function () {\n return session.getValue();\n });\n element.style.display = 'none';\n container.style.background = 'white';\n var editorDiv = document.createElement(\"div\");\n applyStyles(editorDiv, {\n top: \"0px\",\n left: \"0px\",\n right: \"0px\",\n bottom: \"0px\",\n border: \"1px solid gray\",\n position: \"absolute\"\n });\n container.appendChild(editorDiv);\n var settingOpener = document.createElement(\"div\");\n applyStyles(settingOpener, {\n position: \"absolute\",\n right: \"0px\",\n bottom: \"0px\",\n cursor: \"nw-resize\",\n border: \"solid 9px\",\n borderColor: \"lightblue gray gray #ceade6\",\n zIndex: 101\n });\n var settingDiv = document.createElement(\"div\");\n var settingDivStyles = {\n top: \"0px\",\n left: \"20%\",\n right: \"0px\",\n bottom: \"0px\",\n position: \"absolute\",\n padding: \"5px\",\n zIndex: 100,\n color: \"white\",\n display: \"none\",\n overflow: \"auto\",\n fontSize: \"14px\",\n boxShadow: \"-5px 2px 3px gray\"\n };\n if (!UA.isOldIE) {\n settingDivStyles.backgroundColor = \"rgba(0, 0, 0, 0.6)\";\n }\n else {\n settingDivStyles.backgroundColor = \"#333\";\n }\n applyStyles(settingDiv, settingDivStyles);\n container.appendChild(settingDiv);\n options = options || exports.defaultOptions;\n var editor = ace.edit(editorDiv);\n session = editor.getSession();\n session.setValue(element.value || element.innerHTML);\n if (isFocused)\n editor.focus();\n container.appendChild(settingOpener);\n setupApi(editor, editorDiv, settingDiv, ace, options);\n setupSettingPanel(settingDiv, settingOpener, editor);\n var state = \"\";\n event.addListener(settingOpener, \"mousemove\", function (e) {\n var rect = this.getBoundingClientRect();\n var x = e.clientX - rect.left, y = e.clientY - rect.top;\n if (x + y < (rect.width + rect.height) / 2) {\n this.style.cursor = \"pointer\";\n state = \"toggle\";\n }\n else {\n state = \"resize\";\n this.style.cursor = \"nw-resize\";\n }\n });\n event.addListener(settingOpener, \"mousedown\", function (e) {\n e.preventDefault();\n if (state == \"toggle\") {\n editor.setDisplaySettings();\n return;\n }\n container.style.zIndex = 100000;\n var rect = container.getBoundingClientRect();\n var startX = rect.width + rect.left - e.clientX;\n var startY = rect.height + rect.top - e.clientY;\n event.capture(settingOpener, function (e) {\n container.style.width = e.clientX - rect.left + startX + \"px\";\n container.style.height = e.clientY - rect.top + startY + \"px\";\n editor.resize();\n }, function () { });\n });\n return editor;\n};\nfunction setupApi(editor, editorDiv, settingDiv, ace, options) {\n function toBool(value) {\n return value === \"true\" || value == true;\n }\n editor.setDisplaySettings = function (display) {\n if (display == null)\n display = settingDiv.style.display == \"none\";\n if (display) {\n settingDiv.style.display = \"block\";\n settingDiv.hideButton.focus();\n editor.on(\"focus\", function onFocus() {\n editor.removeListener(\"focus\", onFocus);\n settingDiv.style.display = \"none\";\n });\n }\n else {\n editor.focus();\n }\n };\n editor.$setOption = editor.setOption;\n editor.$getOption = editor.getOption;\n editor.setOption = function (key, value) {\n switch (key) {\n case \"mode\":\n editor.$setOption(\"mode\", \"ace/mode/\" + value);\n break;\n case \"theme\":\n editor.$setOption(\"theme\", \"ace/theme/\" + value);\n break;\n case \"keybindings\":\n switch (value) {\n case \"vim\":\n editor.setKeyboardHandler(\"ace/keyboard/vim\");\n break;\n case \"emacs\":\n editor.setKeyboardHandler(\"ace/keyboard/emacs\");\n break;\n default:\n editor.setKeyboardHandler(null);\n }\n break;\n case \"wrap\":\n case \"fontSize\":\n editor.$setOption(key, value);\n break;\n default:\n editor.$setOption(key, toBool(value));\n }\n };\n editor.getOption = function (key) {\n switch (key) {\n case \"mode\":\n return editor.$getOption(\"mode\").substr(\"ace/mode/\".length);\n break;\n case \"theme\":\n return editor.$getOption(\"theme\").substr(\"ace/theme/\".length);\n break;\n case \"keybindings\":\n var value = editor.getKeyboardHandler();\n switch (value && value.$id) {\n case \"ace/keyboard/vim\":\n return \"vim\";\n case \"ace/keyboard/emacs\":\n return \"emacs\";\n default:\n return \"ace\";\n }\n break;\n default:\n return editor.$getOption(key);\n }\n };\n editor.setOptions(options);\n return editor;\n}\nfunction setupSettingPanel(settingDiv, settingOpener, editor) {\n var BOOL = null;\n var desc = {\n mode: \"Mode:\",\n wrap: \"Soft Wrap:\",\n theme: \"Theme:\",\n fontSize: \"Font Size:\",\n showGutter: \"Display Gutter:\",\n keybindings: \"Keyboard\",\n showPrintMargin: \"Show Print Margin:\",\n useSoftTabs: \"Use Soft Tabs:\",\n showInvisibles: \"Show Invisibles\"\n };\n var optionValues = {\n mode: {\n text: \"Plain\",\n javascript: \"JavaScript\",\n xml: \"XML\",\n html: \"HTML\",\n css: \"CSS\",\n scss: \"SCSS\",\n python: \"Python\",\n php: \"PHP\",\n java: \"Java\",\n ruby: \"Ruby\",\n c_cpp: \"C/C++\",\n coffee: \"CoffeeScript\",\n json: \"json\",\n perl: \"Perl\",\n clojure: \"Clojure\",\n ocaml: \"OCaml\",\n csharp: \"C#\",\n haxe: \"haXe\",\n svg: \"SVG\",\n textile: \"Textile\",\n groovy: \"Groovy\",\n liquid: \"Liquid\",\n Scala: \"Scala\"\n },\n theme: {\n clouds: \"Clouds\",\n clouds_midnight: \"Clouds Midnight\",\n cobalt: \"Cobalt\",\n crimson_editor: \"Crimson Editor\",\n dawn: \"Dawn\",\n gob: \"Green on Black\",\n eclipse: \"Eclipse\",\n idle_fingers: \"Idle Fingers\",\n kr_theme: \"Kr Theme\",\n merbivore: \"Merbivore\",\n merbivore_soft: \"Merbivore Soft\",\n mono_industrial: \"Mono Industrial\",\n monokai: \"Monokai\",\n pastel_on_dark: \"Pastel On Dark\",\n solarized_dark: \"Solarized Dark\",\n solarized_light: \"Solarized Light\",\n textmate: \"Textmate\",\n twilight: \"Twilight\",\n vibrant_ink: \"Vibrant Ink\"\n },\n showGutter: BOOL,\n fontSize: {\n \"10px\": \"10px\",\n \"11px\": \"11px\",\n \"12px\": \"12px\",\n \"14px\": \"14px\",\n \"16px\": \"16px\"\n },\n wrap: {\n off: \"Off\",\n 40: \"40\",\n 80: \"80\",\n free: \"Free\"\n },\n keybindings: {\n ace: \"ace\",\n vim: \"vim\",\n emacs: \"emacs\"\n },\n showPrintMargin: BOOL,\n useSoftTabs: BOOL,\n showInvisibles: BOOL\n };\n var table = [];\n table.push(\"
Setting | Value |
---|---|
\", desc[option], \" | \");\n table.push(\"\");\n renderOption(table, option, optionValues[option], editor.getOption(option));\n table.push(\" |