Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4640 from uGoMobi/textinput
Browse files Browse the repository at this point in the history
Fixes #4636 and #4637 - Class ui-disabled was not added during enhancement of disabled textinputs
  • Loading branch information
jaspermdegroot committed Jul 3, 2012
2 parents 7cf44d4 + aa63dc4 commit 1224c0e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
21 changes: 14 additions & 7 deletions docs/forms/search/options.html
Expand Up @@ -38,6 +38,20 @@ <h2>Search input</h2>
<p>The text input plugin has the following options:</p>

<dl>
<dt><code>clearSearchButtonText</code> <em>string</em></dt>
<dd>
<p class="default">default: "clear text"</p>
<p>Sets the text used for the button that clears the search input of text.</p>
<pre><code>$('.selector').textinput(<strong>{ clearSearchButtonText: "custom value" }</strong>);</code></pre>
</dd>

<dt><code>disabled</code> <em>boolean</em></dt>
<dd>
<p class="default">default: false</p>
<p>Sets the default state of the search input to disabled when "true".</p>
<pre><code>$('.selector').textinput(<strong>{ disabled: "true" }</strong>);</code></pre>
</dd>

<dt><code>initSelector</code> <em>CSS selector string</em></dt>
<dd>
<p class="default">default: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input:not([type])"</p>
Expand All @@ -59,13 +73,6 @@ <h2>Search input</h2>
<pre><code>$('.selector').textinput(<strong>{ theme: "a" }</strong>);</code></pre>
</dd>

<dt><code>clearSearchButtonText</code> <em>string</em></dt>
<dd>
<p class="default">default: "clear text"</p>
<p>Sets the text used for the button that clears the search input of text.</p>
<pre><code>$('.selector').textinput(<strong>{ clearSearchButtonText: "custom value" }</strong>);</code></pre>
</dd>

</dl>

</form>
Expand Down
7 changes: 7 additions & 0 deletions docs/forms/textinputs/options.html
Expand Up @@ -38,6 +38,13 @@ <h2>Text inputs</h2>
<p>The text input plugin has the following options:</p>

<dl>
<dt><code>disabled</code> <em>boolean</em></dt>
<dd>
<p class="default">default: false</p>
<p>Sets the default state of the text input to disabled when "true".</p>
<pre><code>$('.selector').textinput(<strong>{ disabled: "true" }</strong>);</code></pre>
</dd>

<dt><code>initSelector</code> <em>CSS selector string</em></dt>
<dd>
<p class="default">default: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input:not([type])"</p>
Expand Down
26 changes: 21 additions & 5 deletions js/widgets/forms/textinput.js
Expand Up @@ -15,7 +15,8 @@ $.widget( "mobile.textinput", $.mobile.widget, {
// This option defaults to true on iOS devices.
preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type])",
clearSearchButtonText: "clear text"
clearSearchButtonText: "clear text",
disabled: false
},

_create: function() {
Expand Down Expand Up @@ -131,16 +132,31 @@ $.widget( "mobile.textinput", $.mobile.widget, {
$( window ).load( keyup );
}
}
if ( input.attr( "disabled" ) ) {
this.disable();
}
},

disable: function(){
( this.element.attr( "disabled", true ).is( "[type='search'],:jqmData(type='search')" ) ?
this.element.parent() : this.element ).addClass( "ui-disabled" );

if ( this.element.attr( "disabled", true ).is( "[type='search'],:jqmData(type='search')" ) ) {
this.element.parent().addClass( "ui-disabled" );
} else {
this.element.addClass( "ui-disabled" );
}
return this._setOption( "disabled", true );

},

enable: function(){
( this.element.attr( "disabled", false).is( "[type='search'],:jqmData(type='search')" ) ?
this.element.parent() : this.element ).removeClass( "ui-disabled" );

if ( this.element.attr( "disabled", false ).is( "[type='search'],:jqmData(type='search')" ) ) {
this.element.parent().removeClass( "ui-disabled" );
} else {
this.element.removeClass( "ui-disabled" );
}
return this._setOption( "disabled", false );

}
});

Expand Down

0 comments on commit 1224c0e

Please sign in to comment.