Skip to content

Commit

Permalink
Make placeholder logic smarter (fixes tiff#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiff committed Jun 14, 2012
1 parent e090eec commit ecb0a29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/dom/simulate_placeholder.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
if (view.hasPlaceholderSet()) { if (view.hasPlaceholderSet()) {
view.clear(); view.clear();
} }
view.placeholderSet = false;
dom.removeClass(view.element, CLASS_NAME); dom.removeClass(view.element, CLASS_NAME);
}, },
set = function() { set = function() {
if (view.isEmpty()) { if (view.isEmpty()) {
view.placeholderSet = true;
view.setValue(placeholderText); view.setValue(placeholderText);
dom.addClass(view.element, CLASS_NAME); dom.addClass(view.element, CLASS_NAME);
} }
Expand Down
2 changes: 1 addition & 1 deletion src/views/composer.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
}, },


hasPlaceholderSet: function() { hasPlaceholderSet: function() {
return this.getTextContent() == this.textarea.element.getAttribute("placeholder"); return this.getTextContent() == this.textarea.element.getAttribute("placeholder") && this.placeholderSet;
}, },


isEmpty: function() { isEmpty: function() {
Expand Down

0 comments on commit ecb0a29

Please sign in to comment.