forked from ionic-team/ionic-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss-docs-angular.js
37 lines (30 loc) · 937 Bytes
/
css-docs-angular.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
angular.module('devicePreview', [])
.directive('itemFloatingLabel', function() {
return {
restrict: 'C',
link: function(scope, element) {
var el = element[0];
var input = el.querySelector('input, textarea');
var inputLabel = el.querySelector('.input-label');
if ( !input || !inputLabel ) return;
var onInput = function() {
if ( input.value ) {
inputLabel.classList.add('has-input');
} else {
inputLabel.classList.remove('has-input');
}
};
input.addEventListener('input', onInput);
var ngModelCtrl = angular.element(input).controller('ngModel');
if ( ngModelCtrl ) {
ngModelCtrl.$render = function() {
input.value = ngModelCtrl.$viewValue || '';
onInput();
};
}
scope.$on('$destroy', function() {
input.removeEventListener('input', onInput);
});
}
};
});