(textarea, options)
| 13115 | TextareaInput.prototype.needsContentAttribute = false |
| 13116 | |
| 13117 | function fromTextArea(textarea, options) { |
| 13118 | options = options ? copyObj(options) : {} |
| 13119 | options.value = textarea.value |
| 13120 | if (!options.tabindex && textarea.tabIndex) { |
| 13121 | options.tabindex = textarea.tabIndex |
| 13122 | } |
| 13123 | if (!options.placeholder && textarea.placeholder) { |
| 13124 | options.placeholder = textarea.placeholder |
| 13125 | } |
| 13126 | // Set autofocus to true if this textarea is focused, or if it has |
| 13127 | // autofocus and no other element is focused. |
| 13128 | if (options.autofocus == null) { |
| 13129 | var hasFocus = activeElt() |
| 13130 | options.autofocus = hasFocus == textarea || (textarea.getAttribute("autofocus") != null && hasFocus == document.body) |
| 13131 | } |
| 13132 | |
| 13133 | function save() { |
| 13134 | textarea.value = cm.getValue() |
| 13135 | } |
| 13136 | |
| 13137 | var realSubmit |
| 13138 | if (textarea.form) { |
| 13139 | on(textarea.form, "submit", save) |
| 13140 | // Deplorable hack to make the submit method do the right thing. |
| 13141 | if (!options.leaveSubmitMethodAlone) { |
| 13142 | var form = textarea.form |
| 13143 | realSubmit = form.submit |
| 13144 | try { |
| 13145 | var wrappedSubmit = (form.submit = function () { |
| 13146 | save() |
| 13147 | form.submit = realSubmit |
| 13148 | form.submit() |
| 13149 | form.submit = wrappedSubmit |
| 13150 | }) |
| 13151 | } catch (e) {} |
| 13152 | } |
| 13153 | } |
| 13154 | |
| 13155 | options.finishInit = function (cm) { |
| 13156 | cm.save = save |
| 13157 | cm.getTextArea = function () { |
| 13158 | return textarea |
| 13159 | } |
| 13160 | cm.toTextArea = function () { |
| 13161 | cm.toTextArea = isNaN // Prevent this from being ran twice |
| 13162 | save() |
| 13163 | textarea.parentNode.removeChild(cm.getWrapperElement()) |
| 13164 | textarea.style.display = "" |
| 13165 | if (textarea.form) { |
| 13166 | off(textarea.form, "submit", save) |
| 13167 | if (typeof textarea.form.submit == "function") { |
| 13168 | textarea.form.submit = realSubmit |
| 13169 | } |
| 13170 | } |
| 13171 | } |
| 13172 | } |
| 13173 | |
| 13174 | textarea.style.display = "none" |
nothing calls this directly
no test coverage detected