+
+
+
+
+
+
+
+
diff --git a/demos/directive/textInput/floatingLabel/index.js b/demos/directive/textInput/floatingLabel/index.js
new file mode 100644
index 0000000000..8b076c3555
--- /dev/null
+++ b/demos/directive/textInput/floatingLabel/index.js
@@ -0,0 +1,12 @@
+---
+name: floatingLabel
+component: itemFloatingLabel
+---
+
+var app = angular.module('floatingLabel', ['ionic']);
+
+app.controller('AppCtrl', function($scope) {
+
+ $scope.favSong = "Tubthumping";
+
+});
diff --git a/demos/directive/textInput/floatingLabel/test.scenario.js b/demos/directive/textInput/floatingLabel/test.scenario.js
new file mode 100644
index 0000000000..c7b7bd7d1a
--- /dev/null
+++ b/demos/directive/textInput/floatingLabel/test.scenario.js
@@ -0,0 +1,25 @@
+---
+name: floatingLabel
+component: itemFloatingLabel
+---
+
+it('should enter text into floating label inputs', function(){
+ var ele = element.all(by.css('label.item-floating-label input, label.item-floating-label textarea'));
+ ele.get(0).sendKeys('Dr. Pumpernickel');
+ ele.get(1).sendKeys('Round House Kicks');
+});
+
+it('should add and remove text from floating label inputs', function(){
+ var ele = element.all(by.css('label.item-floating-label input, label.item-floating-label textarea'));
+
+ for(var x=0; x<'Dr. Pumpernickel'.length; x++) {
+ ele.get(0).sendKeys(protractor.Key.BACK_SPACE);
+ }
+
+ ele.get(1).sendKeys(" To The Face");
+
+ for(var x=0; x<'Tubthumping'.length; x++) {
+ ele.get(2).sendKeys(protractor.Key.BACK_SPACE);
+ }
+
+});
diff --git a/js/angular/directive/itemFloatingLabel.js b/js/angular/directive/itemFloatingLabel.js
index a4a0cd4d84..cb8e5275d3 100644
--- a/js/angular/directive/itemFloatingLabel.js
+++ b/js/angular/directive/itemFloatingLabel.js
@@ -11,11 +11,9 @@ IonicModule
if ( !input || !inputLabel ) return;
var onInput = function() {
- var hasInput = inputLabel.classList.contains('has-input');
- if ( input.value && !hasInput ) {
+ if ( input.value ) {
inputLabel.classList.add('has-input');
- }
- else if ( !input.value && hasInput ) {
+ } else {
inputLabel.classList.remove('has-input');
}
};
@@ -26,8 +24,6 @@ IonicModule
if ( ngModelCtrl ) {
ngModelCtrl.$render = function() {
input.value = ngModelCtrl.$viewValue || '';
- if ( ngModelCtrl.$viewValue ) input.value = ngModelCtrl.$viewValue;
- else input.value = '';
onInput();
};
}