File tree 4 files changed +68
-6
lines changed
demos/directive/textInput/floatingLabel
4 files changed +68
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ name: floatingLabel
3
+ component: itemFloatingLabel
4
+ ---
5
+
6
+ < ion-header-bar class ="bar-positive ">
7
+ < h1 class ="title ">
8
+ Text Input: Floating Label
9
+ </ h1 >
10
+ </ ion-header-bar >
11
+
12
+ < ion-content ng-controller ="AppCtrl ">
13
+
14
+ < div class ="list ">
15
+ < label class ="item item-input item-floating-label ">
16
+ < span class ="input-label "> Name</ span >
17
+ < input type ="text " placeholder ="Name ">
18
+ </ label >
19
+ < label class ="item item-input item-floating-label ">
20
+ < span class ="input-label "> Profession</ span >
21
+ < input type ="text " placeholder ="Profession ">
22
+ </ label >
23
+ < label class ="item item-input item-floating-label ">
24
+ < span class ="input-label "> Favorite Song</ span >
25
+ < textarea placeholder ="Favorite Song " ng-model ="favSong "> </ textarea >
26
+ </ label >
27
+ </ div >
28
+
29
+ </ ion-content >
Original file line number Diff line number Diff line change
1
+ -- -
2
+ name : floatingLabel
3
+ component: itemFloatingLabel
4
+ -- -
5
+
6
+ var app = angular . module ( 'floatingLabel' , [ 'ionic' ] ) ;
7
+
8
+ app . controller ( 'AppCtrl' , function ( $scope ) {
9
+
10
+ $scope . favSong = "Tubthumping" ;
11
+
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ -- -
2
+ name : floatingLabel
3
+ component: itemFloatingLabel
4
+ -- -
5
+
6
+ it ( 'should enter text into floating label inputs' , function ( ) {
7
+ var ele = element . all ( by . css ( 'label.item-floating-label input, label.item-floating-label textarea' ) ) ;
8
+ ele . get ( 0 ) . sendKeys ( 'Dr. Pumpernickel' ) ;
9
+ ele . get ( 1 ) . sendKeys ( 'Round House Kicks' ) ;
10
+ } ) ;
11
+
12
+ it ( 'should add and remove text from floating label inputs' , function ( ) {
13
+ var ele = element . all ( by . css ( 'label.item-floating-label input, label.item-floating-label textarea' ) ) ;
14
+
15
+ for ( var x = 0 ; x < 'Dr. Pumpernickel' . length ; x ++ ) {
16
+ ele . get ( 0 ) . sendKeys ( protractor . Key . BACK_SPACE ) ;
17
+ }
18
+
19
+ ele . get ( 1 ) . sendKeys ( " To The Face" ) ;
20
+
21
+ for ( var x = 0 ; x < 'Tubthumping' . length ; x ++ ) {
22
+ ele . get ( 2 ) . sendKeys ( protractor . Key . BACK_SPACE ) ;
23
+ }
24
+
25
+ } ) ;
Original file line number Diff line number Diff line change @@ -11,11 +11,9 @@ IonicModule
11
11
if ( ! input || ! inputLabel ) return ;
12
12
13
13
var onInput = function ( ) {
14
- var hasInput = inputLabel . classList . contains ( 'has-input' ) ;
15
- if ( input . value && ! hasInput ) {
14
+ if ( input . value ) {
16
15
inputLabel . classList . add ( 'has-input' ) ;
17
- }
18
- else if ( ! input . value && hasInput ) {
16
+ } else {
19
17
inputLabel . classList . remove ( 'has-input' ) ;
20
18
}
21
19
} ;
@@ -26,8 +24,6 @@ IonicModule
26
24
if ( ngModelCtrl ) {
27
25
ngModelCtrl . $render = function ( ) {
28
26
input . value = ngModelCtrl . $viewValue || '' ;
29
- if ( ngModelCtrl . $viewValue ) input . value = ngModelCtrl . $viewValue ;
30
- else input . value = '' ;
31
27
onInput ( ) ;
32
28
} ;
33
29
}
You can’t perform that action at this time.
0 commit comments