Standardized hints while providing backwards compatibility on data-hint

This commit is contained in:
Kevin Ross 2015-11-06 10:34:41 -06:00
parent 59811e4ca5
commit e8bb88c79c
2 changed files with 7 additions and 6 deletions

View File

@ -506,7 +506,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control floating-label" placeholder="old floating label" data-hint="old hint attribute"> <input type="text" class="form-control floating-label" placeholder="old floating label" data-hint="This is a hint using a <code>data-hint</code> attribute on the input">
</div> </div>
<h2>Textarea</h2> <h2>Textarea</h2>

View File

@ -78,9 +78,9 @@
console.error("Expected form-group for input", $this); console.error("Expected form-group for input", $this);
} }
if (!$this.attr("data-hint") && !$this.hasClass("floating-label")) { //if (!$this.attr("data-hint") && !$this.hasClass("floating-label")) {
return; // return;
} //}
$this.after("<span class=material-input></span>"); $this.after("<span class=material-input></span>");
@ -91,9 +91,10 @@
$this.after("<div class=floating-label>" + placeholder + "</div>"); $this.after("<div class=floating-label>" + placeholder + "</div>");
} }
// Add hint label if required
// Add hint label if using the shorthand data-hint attribute on the input
if ($this.attr("data-hint")) { if ($this.attr("data-hint")) {
$this.after("<div class=hint>" + $this.attr("data-hint") + "</div>"); $this.after("<p class='help-block hint'>" + $this.attr("data-hint") + "</p>");
} }
// Set as empty if is empty (damn I must improve this...) // Set as empty if is empty (damn I must improve this...)