Permalink
Browse files

Merge pull request #4640 from uGoMobi/textinput

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 1224c0ef9c51541b1c8ed7afc57359eea4b0ac17
Showing with 42 additions and 12 deletions.
  1. +14 −7 docs/forms/search/options.html
  2. +7 −0 docs/forms/textinputs/options.html
  3. +21 −5 js/widgets/forms/textinput.js
@@ -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>
@@ -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>
@@ -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>
@@ -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() {
@@ -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 );
}
});

0 comments on commit 1224c0e

Please sign in to comment.