Skip to content

Commit

Permalink
Merge pull request #40 from jaimevent/master
Browse files Browse the repository at this point in the history
Type of input can be set through parameter
  • Loading branch information
Stefan Gasser committed Apr 2, 2015
2 parents 195ccd8 + 085c3e5 commit 4e0196a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
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);
});

0 comments on commit 4e0196a

Please sign in to comment.