Skip to content
This repository
Browse code

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...
commit 1224c0ef9c51541b1c8ed7afc57359eea4b0ac17 2 parents 7cf44d4 + aa63dc4
Jasper de Groot authored July 03, 2012
21  docs/forms/search/options.html
@@ -38,6 +38,20 @@
38 38
 			<p>The text input plugin has the following options:</p>
39 39
 
40 40
 		<dl>
  41
+			<dt><code>clearSearchButtonText</code> <em>string</em></dt>
  42
+			<dd>
  43
+				<p class="default">default: "clear text"</p>
  44
+				<p>Sets the text used for the button that clears the search input of text.</p>
  45
+				<pre><code>$('.selector').textinput(<strong>{ clearSearchButtonText: "custom value" }</strong>);</code></pre>
  46
+			</dd>
  47
+			
  48
+			<dt><code>disabled</code> <em>boolean</em></dt>
  49
+			<dd>
  50
+				<p class="default">default: false</p>
  51
+				<p>Sets the default state of the search input to disabled when "true".</p>		
  52
+				<pre><code>$('.selector').textinput(<strong>{ disabled: "true" }</strong>);</code></pre>
  53
+			</dd>
  54
+		
41 55
 			<dt><code>initSelector</code> <em>CSS selector string</em></dt>
42 56
 			<dd>
43 57
 				<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 @@
59 73
 				<pre><code>$('.selector').textinput(<strong>{ theme: "a" }</strong>);</code></pre>
60 74
 			</dd>
61 75
 			
62  
-			<dt><code>clearSearchButtonText</code> <em>string</em></dt>
63  
-			<dd>
64  
-				<p class="default">default: "clear text"</p>
65  
-				<p>Sets the text used for the button that clears the search input of text.</p>
66  
-				<pre><code>$('.selector').textinput(<strong>{ clearSearchButtonText: "custom value" }</strong>);</code></pre>
67  
-			</dd>
68  
-			
69 76
 		</dl>
70 77
     
71 78
 	</form>
7  docs/forms/textinputs/options.html
@@ -38,6 +38,13 @@
38 38
 			<p>The text input plugin has the following options:</p>
39 39
 
40 40
 		<dl>
  41
+			<dt><code>disabled</code> <em>boolean</em></dt>
  42
+			<dd>
  43
+				<p class="default">default: false</p>
  44
+				<p>Sets the default state of the text input to disabled when "true".</p>		
  45
+				<pre><code>$('.selector').textinput(<strong>{ disabled: "true" }</strong>);</code></pre>
  46
+			</dd>
  47
+			
41 48
 			<dt><code>initSelector</code> <em>CSS selector string</em></dt>
42 49
 			<dd>
43 50
 				<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>
26  js/widgets/forms/textinput.js
@@ -15,7 +15,8 @@ $.widget( "mobile.textinput", $.mobile.widget, {
15 15
 		// This option defaults to true on iOS devices.
16 16
 		preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1,
17 17
 		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])",
18  
-		clearSearchButtonText: "clear text"
  18
+		clearSearchButtonText: "clear text",
  19
+		disabled: false
19 20
 	},
20 21
 
21 22
 	_create: function() {
@@ -131,16 +132,31 @@ $.widget( "mobile.textinput", $.mobile.widget, {
131 132
 				$( window ).load( keyup );
132 133
 			}
133 134
 		}
  135
+		if ( input.attr( "disabled" ) ) {
  136
+			this.disable();
  137
+		}
134 138
 	},
135 139
 
136 140
 	disable: function(){
137  
-		( this.element.attr( "disabled", true ).is( "[type='search'],:jqmData(type='search')" ) ?
138  
-			this.element.parent() : this.element ).addClass( "ui-disabled" );
  141
+		
  142
+		if ( this.element.attr( "disabled", true ).is( "[type='search'],:jqmData(type='search')" ) ) {
  143
+			this.element.parent().addClass( "ui-disabled" );
  144
+		} else {
  145
+			this.element.addClass( "ui-disabled" );
  146
+		}
  147
+		return this._setOption( "disabled", true );
  148
+			
139 149
 	},
140 150
 
141 151
 	enable: function(){
142  
-		( this.element.attr( "disabled", false).is( "[type='search'],:jqmData(type='search')" ) ?
143  
-			this.element.parent() : this.element ).removeClass( "ui-disabled" );
  152
+		
  153
+		if ( this.element.attr( "disabled", false ).is( "[type='search'],:jqmData(type='search')" ) ) {
  154
+			this.element.parent().removeClass( "ui-disabled" );
  155
+		} else {
  156
+			this.element.removeClass( "ui-disabled" );
  157
+		}
  158
+		return this._setOption( "disabled", false );
  159
+			
144 160
 	}
145 161
 });
146 162
 

0 notes on commit 1224c0e

Please sign in to comment.
Something went wrong with that request. Please try again.