From aeb8d0d1e6774a2c0bac8426656407f714e6d31d Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 8 Jun 2013 17:30:54 +0100 Subject: [PATCH] Allow a placeholder attribute to be specified on the edit widget Also fix some problems with handling of the class and style attributes --- core/modules/widgets/edit/editors/texteditor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/edit/editors/texteditor.js b/core/modules/widgets/edit/editors/texteditor.js index 44330bd2a..5eb19cf6f 100644 --- a/core/modules/widgets/edit/editors/texteditor.js +++ b/core/modules/widgets/edit/editors/texteditor.js @@ -76,17 +76,21 @@ TextEditor.prototype.render = function() { node.attributes.value = {type: "string", value: editInfo.value}; break; } + // Add a placeholder if specified + if(this.editWidget.renderer.hasAttribute("placeholder")) { + node.attributes.placeholder = {type: "string", value: this.editWidget.renderer.getAttribute("placeholder")}; + } // Set the element details this.editWidget.tag = this.editWidget.renderer.parseTreeNode.isBlock ? "div" : "span"; this.editWidget.attributes = { "class": "tw-edit-texteditor" }; - if(this.editWidget.renderer.parseTreeNode.attributes["class"]) { - this.editWidget.attributes["class"] += " " + this.editWidget.renderer.parseTreeNode.attributes["class"].value; + if(this.editWidget.renderer.hasAttribute("class")) { + this.editWidget.attributes["class"] += " " + this.editWidget.renderer.getAttribute("class"); } - if(this.editWidget.renderer.parseTreeNode.attributes.style) { + if(this.editWidget.renderer.hasAttribute("style")) { this.editWidget.attributes.style = this.editWidget.attributes.style || ""; - this.editWidget.attributes.style += this.editWidget.renderer.parseTreeNode.attributes.style.value; + this.editWidget.attributes.style += this.editWidget.renderer.getAttribute("style"); } this.editWidget.children = this.editWidget.renderer.renderTree.createRenderers(this.editWidget.renderer,[node]); this.editWidget.events = [