Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type of input can be set through parameter #40

Merged
merged 4 commits into from
Apr 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/components/materialize-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import layout from '../templates/components/materialize-input';

export default MaterializeInputField.extend({
layout: layout,
type: 'text',
didInsertElement: function() {
this._super();
// make sure the label moves when a value is bound.
Expand All @@ -13,4 +14,3 @@ export default MaterializeInputField.extend({
}
}
});

3 changes: 1 addition & 2 deletions addon/templates/components/materialize-input.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{{#if icon}}
<i {{bind-attr class="icon :prefix"}}></i>
{{/if}}
{{input id=id value=value classNameBindings="validate:validate: errors.firstObject:invalid:valid" type="text"
{{input id=id value=value classNameBindings="validate:validate: errors.firstObject:invalid:valid" type=type
required=required pattern=pattern maxlength=maxlength readonly=readonly disabled=disabled
autocomplete=autocomplete}}
<label {{bind-attr for=id}}>{{label}}</label>
<small class="red-text">
{{#if errors}} {{errors.firstObject}} {{else}} &nbsp; {{/if}}
</small>

16 changes: 15 additions & 1 deletion tests/dummy/app/templates/input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<li>label, default value <span class="default-value badge">null</span></li>
<li>icon, default value <span class="default-value badge">null</span></li>
<li>value, default value <span class="default-value badge">null</span></li>
<li>type, default value <span class="default-value badge">text</span></li>
<li>required, default value <span class="default-value badge">false</span></li>
<li>readonly, default value <span class="default-value badge">false</span></li>
<li>disabled, default value <span class="default-value badge">false</span></li>
Expand Down Expand Up @@ -56,6 +57,20 @@
</div>
</div>

<div class="section">
<h4 class="col s12 header">Input with type="password"</h4>
<div class="button-example">
<br/>
{{materialize-input value="test" label='Password' type="password"}}

<pre class=" language-markup">
<code class=" col s12 language-markup">
<span>&#123;&#123;</span>materialize-input value="test" label="Password" type="password"<span>&#125;&#125;</span>
</code>
</pre>
</div>
</div>


<div class="section">
<h4 class="col s12 header">Validations</h4>
Expand Down Expand Up @@ -177,4 +192,3 @@ nameDidChange: function() {
</div>

</div>

7 changes: 7 additions & 0 deletions tests/unit/components/materialize-input-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ test('has an icon', function(assert) {
this.render();
assert.ok(component.$('>i').hasClass(icon));
});

test('has type password', function(assert) {
var type = 'password';
var component = this.subject({ type: type });
this.render();
assert.equal(component.$('>input').attr('type'), type);
});