Neues Initialrelease mit IonicMaterial
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*!
|
||||
* Angular Material Design
|
||||
* https://github.com/angular/material
|
||||
* @license MIT
|
||||
* v0.10.0
|
||||
*/
|
||||
/* mixin definition ; sets LTR and RTL within the same style call */
|
||||
md-input-container.md-THEME_NAME-theme .md-input {
|
||||
color: '{{foreground-1}}';
|
||||
border-color: '{{foreground-4}}';
|
||||
text-shadow: '{{foreground-shadow}}'; }
|
||||
md-input-container.md-THEME_NAME-theme .md-input::-webkit-input-placeholder, md-input-container.md-THEME_NAME-theme .md-input::-moz-placeholder, md-input-container.md-THEME_NAME-theme .md-input:-moz-placeholder, md-input-container.md-THEME_NAME-theme .md-input:-ms-input-placeholder {
|
||||
color: '{{foreground-3}}'; }
|
||||
md-input-container.md-THEME_NAME-theme > md-icon {
|
||||
color: '{{foreground-1}}'; }
|
||||
md-input-container.md-THEME_NAME-theme label, md-input-container.md-THEME_NAME-theme .md-placeholder {
|
||||
text-shadow: '{{foreground-shadow}}';
|
||||
color: '{{foreground-3}}'; }
|
||||
md-input-container.md-THEME_NAME-theme ng-messages, md-input-container.md-THEME_NAME-theme [ng-message], md-input-container.md-THEME_NAME-theme [data-ng-message], md-input-container.md-THEME_NAME-theme [x-ng-message] {
|
||||
color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-has-value label {
|
||||
color: '{{foreground-2}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused .md-input {
|
||||
border-color: '{{primary-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused label {
|
||||
color: '{{primary-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused md-icon {
|
||||
color: '{{primary-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused.md-accent .md-input {
|
||||
border-color: '{{accent-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused.md-accent label {
|
||||
color: '{{accent-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused.md-warn .md-input {
|
||||
border-color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme:not(.md-input-invalid).md-input-focused.md-warn label {
|
||||
color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme.md-input-invalid .md-input {
|
||||
border-color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme.md-input-invalid.md-input-focused label {
|
||||
color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme.md-input-invalid ng-message, md-input-container.md-THEME_NAME-theme.md-input-invalid data-ng-message, md-input-container.md-THEME_NAME-theme.md-input-invalid x-ng-message, md-input-container.md-THEME_NAME-theme.md-input-invalid [ng-message], md-input-container.md-THEME_NAME-theme.md-input-invalid [data-ng-message], md-input-container.md-THEME_NAME-theme.md-input-invalid [x-ng-message], md-input-container.md-THEME_NAME-theme.md-input-invalid .md-char-counter {
|
||||
color: '{{warn-500}}'; }
|
||||
md-input-container.md-THEME_NAME-theme .md-input[disabled], [disabled] md-input-container.md-THEME_NAME-theme .md-input {
|
||||
border-bottom-color: transparent;
|
||||
color: '{{foreground-3}}';
|
||||
background-image: linear-gradient(to right, '{{foreground-3}}' 0%, '{{foreground-3}}' 33%, transparent 0%); }
|
||||
162
www/lib/angular-material/modules/closure/input/input.css
Normal file
162
www/lib/angular-material/modules/closure/input/input.css
Normal file
@@ -0,0 +1,162 @@
|
||||
/*!
|
||||
* Angular Material Design
|
||||
* https://github.com/angular/material
|
||||
* @license MIT
|
||||
* v0.10.0
|
||||
*/
|
||||
/* mixin definition ; sets LTR and RTL within the same style call */
|
||||
md-input-container {
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
position: relative;
|
||||
-webkit-flex-direction: column;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
padding: 2px;
|
||||
padding-bottom: 26px;
|
||||
/*
|
||||
* The .md-input class is added to the input/textarea
|
||||
*/ }
|
||||
md-input-container > md-icon {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 2px; }
|
||||
md-input-container > md-icon + input {
|
||||
margin-left: 36px; }
|
||||
md-input-container textarea, md-input-container input[type="text"], md-input-container input[type="password"], md-input-container input[type="datetime"], md-input-container input[type="datetime-local"], md-input-container input[type="date"], md-input-container input[type="month"], md-input-container input[type="time"], md-input-container input[type="week"], md-input-container input[type="number"], md-input-container input[type="email"], md-input-container input[type="url"], md-input-container input[type="search"], md-input-container input[type="tel"], md-input-container input[type="color"] {
|
||||
/* remove default appearance from all input/textarea */
|
||||
-moz-appearance: none;
|
||||
-webkit-appearance: none; }
|
||||
md-input-container input[type="date"], md-input-container input[type="datetime-local"], md-input-container input[type="month"], md-input-container input[type="time"], md-input-container input[type="week"] {
|
||||
min-height: 26px; }
|
||||
md-input-container textarea {
|
||||
resize: none;
|
||||
overflow: hidden; }
|
||||
md-input-container textarea.md-input {
|
||||
min-height: 56px;
|
||||
-ms-flex-preferred-size: auto; }
|
||||
md-input-container label {
|
||||
position: relative;
|
||||
top: -2px; }
|
||||
md-input-container label:not(.md-no-float), md-input-container .md-placeholder:not(.md-select-label) {
|
||||
-webkit-order: 1;
|
||||
-ms-flex-order: 1;
|
||||
order: 1;
|
||||
pointer-events: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
padding-left: 2px;
|
||||
z-index: 1;
|
||||
-webkit-transform: translate3d(0, 28px, 0) scale(1);
|
||||
transform: translate3d(0, 28px, 0) scale(1);
|
||||
transition: -webkit-transform cubic-bezier(0.25, 0.8, 0.25, 1) 0.25s;
|
||||
transition: transform cubic-bezier(0.25, 0.8, 0.25, 1) 0.25s;
|
||||
-webkit-transform-origin: left top;
|
||||
transform-origin: left top; }
|
||||
html[dir=rtl] md-input-container label:not(.md-no-float), html[dir=rtl] md-input-container .md-placeholder:not(.md-select-label) {
|
||||
-webkit-transform-origin: right top;
|
||||
transform-origin: right top; }
|
||||
md-input-container .md-placeholder:not(.md-select-label) {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
opacity: 0;
|
||||
transition-property: opacity, -webkit-transform;
|
||||
transition-property: opacity, transform;
|
||||
-webkit-transform: translate3d(0, 30px, 0);
|
||||
transform: translate3d(0, 30px, 0); }
|
||||
md-input-container.md-input-focused .md-placeholder {
|
||||
opacity: 1;
|
||||
-webkit-transform: translate3d(0, 24px, 0);
|
||||
transform: translate3d(0, 24px, 0); }
|
||||
md-input-container.md-input-has-value .md-placeholder {
|
||||
transition: none;
|
||||
opacity: 0; }
|
||||
md-input-container:not(.md-input-has-value) input:not(:focus) {
|
||||
color: transparent; }
|
||||
md-input-container .md-input {
|
||||
-webkit-flex: 1 1 auto;
|
||||
-ms-flex: 1 1 auto;
|
||||
flex: 1 1 auto;
|
||||
-webkit-order: 2;
|
||||
-ms-flex-order: 2;
|
||||
order: 2;
|
||||
display: block;
|
||||
background: none;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 1px;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
border-width: 0 0 1px 0;
|
||||
line-height: 26px;
|
||||
-ms-flex-preferred-size: 26px;
|
||||
border-radius: 0; }
|
||||
md-input-container .md-input:focus {
|
||||
outline: none; }
|
||||
md-input-container .md-input:invalid {
|
||||
outline: none;
|
||||
box-shadow: none; }
|
||||
md-input-container ng-messages, md-input-container data-ng-messages, md-input-container x-ng-messages, md-input-container [ng-messages], md-input-container [data-ng-messages], md-input-container [x-ng-messages] {
|
||||
-webkit-order: 3;
|
||||
-ms-flex-order: 3;
|
||||
order: 3;
|
||||
position: relative; }
|
||||
md-input-container ng-message, md-input-container data-ng-message, md-input-container x-ng-message, md-input-container [ng-message], md-input-container [data-ng-message], md-input-container [x-ng-message], md-input-container .md-char-counter {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
position: absolute;
|
||||
font-size: 12px;
|
||||
line-height: 24px; }
|
||||
md-input-container ng-message:not(.md-char-counter), md-input-container data-ng-message:not(.md-char-counter), md-input-container x-ng-message:not(.md-char-counter), md-input-container [ng-message]:not(.md-char-counter), md-input-container [data-ng-message]:not(.md-char-counter), md-input-container [x-ng-message]:not(.md-char-counter), md-input-container .md-char-counter:not(.md-char-counter) {
|
||||
padding-right: 30px; }
|
||||
md-input-container ng-message.ng-enter, md-input-container data-ng-message.ng-enter, md-input-container x-ng-message.ng-enter, md-input-container [ng-message].ng-enter, md-input-container [data-ng-message].ng-enter, md-input-container [x-ng-message].ng-enter, md-input-container .md-char-counter.ng-enter {
|
||||
transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
||||
transition-delay: 0.2s; }
|
||||
md-input-container ng-message.ng-leave, md-input-container data-ng-message.ng-leave, md-input-container x-ng-message.ng-leave, md-input-container [ng-message].ng-leave, md-input-container [data-ng-message].ng-leave, md-input-container [x-ng-message].ng-leave, md-input-container .md-char-counter.ng-leave {
|
||||
transition: all 0.3s cubic-bezier(0.55, 0, 0.55, 0.2); }
|
||||
md-input-container ng-message.ng-enter, md-input-container ng-message.ng-leave.ng-leave-active, md-input-container data-ng-message.ng-enter, md-input-container data-ng-message.ng-leave.ng-leave-active, md-input-container x-ng-message.ng-enter, md-input-container x-ng-message.ng-leave.ng-leave-active, md-input-container [ng-message].ng-enter, md-input-container [ng-message].ng-leave.ng-leave-active, md-input-container [data-ng-message].ng-enter, md-input-container [data-ng-message].ng-leave.ng-leave-active, md-input-container [x-ng-message].ng-enter, md-input-container [x-ng-message].ng-leave.ng-leave-active, md-input-container .md-char-counter.ng-enter, md-input-container .md-char-counter.ng-leave.ng-leave-active {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -20%, 0);
|
||||
transform: translate3d(0, -20%, 0); }
|
||||
md-input-container ng-message.ng-leave, md-input-container ng-message.ng-enter.ng-enter-active, md-input-container data-ng-message.ng-leave, md-input-container data-ng-message.ng-enter.ng-enter-active, md-input-container x-ng-message.ng-leave, md-input-container x-ng-message.ng-enter.ng-enter-active, md-input-container [ng-message].ng-leave, md-input-container [ng-message].ng-enter.ng-enter-active, md-input-container [data-ng-message].ng-leave, md-input-container [data-ng-message].ng-enter.ng-enter-active, md-input-container [x-ng-message].ng-leave, md-input-container [x-ng-message].ng-enter.ng-enter-active, md-input-container .md-char-counter.ng-leave, md-input-container .md-char-counter.ng-enter.ng-enter-active {
|
||||
opacity: 1;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0); }
|
||||
md-input-container .md-char-counter {
|
||||
bottom: 2px;
|
||||
right: 2px; }
|
||||
md-input-container.md-input-focused label:not(.md-no-float), md-input-container.md-input-has-value label:not(.md-no-float) {
|
||||
-webkit-transform: translate3d(0, 6px, 0) scale(0.75);
|
||||
transform: translate3d(0, 6px, 0) scale(0.75); }
|
||||
md-input-container.md-input-focused .md-input, md-input-container .md-input.ng-invalid.ng-dirty {
|
||||
padding-bottom: 0;
|
||||
border-width: 0 0 2px 0; }
|
||||
md-input-container .md-input[disabled], [disabled] md-input-container .md-input {
|
||||
background-position: 0 bottom;
|
||||
background-size: 4px 1px;
|
||||
background-repeat: repeat-x;
|
||||
margin-bottom: -1px; }
|
||||
|
||||
md-input-container.md-icon-float {
|
||||
margin-top: -16px;
|
||||
transition: margin-top 0.5s cubic-bezier(0.25, 0.8, 0.25, 1); }
|
||||
md-input-container.md-icon-float > label {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
margin-left: 36px; }
|
||||
md-input-container.md-icon-float > md-icon {
|
||||
top: 26px;
|
||||
left: 2px; }
|
||||
md-input-container.md-icon-float > md-icon + input {
|
||||
margin-left: 36px; }
|
||||
md-input-container.md-icon-float > input {
|
||||
padding-top: 24px; }
|
||||
md-input-container.md-icon-float.md-input-focused, md-input-container.md-icon-float.md-input-has-value {
|
||||
margin-top: -8px; }
|
||||
md-input-container.md-icon-float.md-input-focused label, md-input-container.md-icon-float.md-input-has-value label {
|
||||
-webkit-transform: translate3d(0, 6px, 0) scale(0.75);
|
||||
transform: translate3d(0, 6px, 0) scale(0.75);
|
||||
transition: -webkit-transform cubic-bezier(0.25, 0.8, 0.25, 1) 0.5s;
|
||||
transition: transform cubic-bezier(0.25, 0.8, 0.25, 1) 0.5s; }
|
||||
|
||||
@media screen and (-ms-high-contrast: active) {
|
||||
md-input-container.md-default-theme > md-icon {
|
||||
fill: #fff; } }
|
||||
371
www/lib/angular-material/modules/closure/input/input.js
vendored
Normal file
371
www/lib/angular-material/modules/closure/input/input.js
vendored
Normal file
@@ -0,0 +1,371 @@
|
||||
/*!
|
||||
* Angular Material Design
|
||||
* https://github.com/angular/material
|
||||
* @license MIT
|
||||
* v0.10.0
|
||||
*/
|
||||
goog.provide('ng.material.components.input');
|
||||
goog.require('ng.material.core');
|
||||
/**
|
||||
* @ngdoc module
|
||||
* @name material.components.input
|
||||
*/
|
||||
|
||||
angular.module('material.components.input', [
|
||||
'material.core'
|
||||
])
|
||||
.directive('mdInputContainer', mdInputContainerDirective)
|
||||
.directive('label', labelDirective)
|
||||
.directive('input', inputTextareaDirective)
|
||||
.directive('textarea', inputTextareaDirective)
|
||||
.directive('mdMaxlength', mdMaxlengthDirective)
|
||||
.directive('placeholder', placeholderDirective);
|
||||
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name mdInputContainer
|
||||
* @module material.components.input
|
||||
*
|
||||
* @restrict E
|
||||
*
|
||||
* @description
|
||||
* `<md-input-container>` is the parent of any input or textarea element.
|
||||
*
|
||||
* Input and textarea elements will not behave properly unless the md-input-container
|
||||
* parent is provided.
|
||||
*
|
||||
* @param md-is-error {expression=} When the given expression evaluates to true, the input container will go into error state. Defaults to erroring if the input has been touched and is invalid.
|
||||
* @param md-no-float {boolean=} When present, placeholders will not be converted to floating labels
|
||||
*
|
||||
* @usage
|
||||
* <hljs lang="html">
|
||||
*
|
||||
* <md-input-container>
|
||||
* <label>Username</label>
|
||||
* <input type="text" ng-model="user.name">
|
||||
* </md-input-container>
|
||||
*
|
||||
* <md-input-container>
|
||||
* <label>Description</label>
|
||||
* <textarea ng-model="user.description"></textarea>
|
||||
* </md-input-container>
|
||||
*
|
||||
* </hljs>
|
||||
*/
|
||||
function mdInputContainerDirective($mdTheming, $parse) {
|
||||
ContainerCtrl.$inject = ["$scope", "$element", "$attrs"];
|
||||
return {
|
||||
restrict: 'E',
|
||||
link: postLink,
|
||||
controller: ContainerCtrl
|
||||
};
|
||||
|
||||
function postLink(scope, element, attr) {
|
||||
$mdTheming(element);
|
||||
}
|
||||
function ContainerCtrl($scope, $element, $attrs) {
|
||||
var self = this;
|
||||
|
||||
self.isErrorGetter = $attrs.mdIsError && $parse($attrs.mdIsError);
|
||||
|
||||
self.delegateClick = function() {
|
||||
self.input.focus();
|
||||
};
|
||||
self.element = $element;
|
||||
self.setFocused = function(isFocused) {
|
||||
$element.toggleClass('md-input-focused', !!isFocused);
|
||||
};
|
||||
self.setHasValue = function(hasValue) {
|
||||
$element.toggleClass('md-input-has-value', !!hasValue);
|
||||
};
|
||||
self.setInvalid = function(isInvalid) {
|
||||
$element.toggleClass('md-input-invalid', !!isInvalid);
|
||||
};
|
||||
$scope.$watch(function() {
|
||||
return self.label && self.input;
|
||||
}, function(hasLabelAndInput) {
|
||||
if (hasLabelAndInput && !self.label.attr('for')) {
|
||||
self.label.attr('for', self.input.attr('id'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
mdInputContainerDirective.$inject = ["$mdTheming", "$parse"];
|
||||
|
||||
function labelDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
require: '^?mdInputContainer',
|
||||
link: function(scope, element, attr, containerCtrl) {
|
||||
if (!containerCtrl || attr.mdNoFloat) return;
|
||||
|
||||
containerCtrl.label = element;
|
||||
scope.$on('$destroy', function() {
|
||||
containerCtrl.label = null;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name mdInput
|
||||
* @restrict E
|
||||
* @module material.components.input
|
||||
*
|
||||
* @description
|
||||
* Use the `<input>` or the `<textarea>` as a child of an `<md-input-container>`.
|
||||
*
|
||||
* @param {number=} md-maxlength The maximum number of characters allowed in this input. If this is specified, a character counter will be shown underneath the input.<br/><br/>
|
||||
* The purpose of **`md-maxlength`** is exactly to show the max length counter text. If you don't want the counter text and only need "plain" validation, you can use the "simple" `ng-maxlength` or maxlength attributes.
|
||||
* @param {string=} aria-label Aria-label is required when no label is present. A warning message will be logged in the console if not present.
|
||||
* @param {string=} placeholder An alternative approach to using aria-label when the label is not present. The placeholder text is copied to the aria-label attribute.
|
||||
*
|
||||
* @usage
|
||||
* <hljs lang="html">
|
||||
* <md-input-container>
|
||||
* <label>Color</label>
|
||||
* <input type="text" ng-model="color" required md-maxlength="10">
|
||||
* </md-input-container>
|
||||
* </hljs>
|
||||
* <h3>With Errors</h3>
|
||||
*
|
||||
* <hljs lang="html">
|
||||
* <form name="userForm">
|
||||
* <md-input-container>
|
||||
* <label>Last Name</label>
|
||||
* <input name="lastName" ng-model="lastName" required md-maxlength="10" minlength="4">
|
||||
* <div ng-messages="userForm.lastName.$error" ng-show="userForm.lastName.$dirty">
|
||||
* <div ng-message="required">This is required!</div>
|
||||
* <div ng-message="md-maxlength">That's too long!</div>
|
||||
* <div ng-message="minlength">That's too short!</div>
|
||||
* </div>
|
||||
* </md-input-container>
|
||||
* <md-input-container>
|
||||
* <label>Biography</label>
|
||||
* <textarea name="bio" ng-model="biography" required md-maxlength="150"></textarea>
|
||||
* <div ng-messages="userForm.bio.$error" ng-show="userForm.bio.$dirty">
|
||||
* <div ng-message="required">This is required!</div>
|
||||
* <div ng-message="md-maxlength">That's too long!</div>
|
||||
* </div>
|
||||
* </md-input-container>
|
||||
* <md-input-container>
|
||||
* <input aria-label='title' ng-model='title'>
|
||||
* </md-input-container>
|
||||
* <md-input-container>
|
||||
* <input placeholder='title' ng-model='title'>
|
||||
* </md-input-container>
|
||||
* </form>
|
||||
* </hljs>
|
||||
*
|
||||
* Requires [ngMessages](https://docs.angularjs.org/api/ngMessages).
|
||||
* Behaves like the [AngularJS input directive](https://docs.angularjs.org/api/ng/directive/input).
|
||||
*
|
||||
*/
|
||||
|
||||
function inputTextareaDirective($mdUtil, $window, $mdAria) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
require: ['^?mdInputContainer', '?ngModel'],
|
||||
link: postLink
|
||||
};
|
||||
|
||||
function postLink(scope, element, attr, ctrls) {
|
||||
|
||||
var containerCtrl = ctrls[0];
|
||||
var ngModelCtrl = ctrls[1] || $mdUtil.fakeNgModel();
|
||||
var isReadonly = angular.isDefined(attr.readonly);
|
||||
|
||||
if ( !containerCtrl ) return;
|
||||
if (containerCtrl.input) {
|
||||
throw new Error("<md-input-container> can only have *one* <input> or <textarea> child element!");
|
||||
}
|
||||
containerCtrl.input = element;
|
||||
|
||||
if(!containerCtrl.label) {
|
||||
$mdAria.expect(element, 'aria-label', element.attr('placeholder'));
|
||||
}
|
||||
|
||||
element.addClass('md-input');
|
||||
if (!element.attr('id')) {
|
||||
element.attr('id', 'input_' + $mdUtil.nextUid());
|
||||
}
|
||||
|
||||
if (element[0].tagName.toLowerCase() === 'textarea') {
|
||||
setupTextarea();
|
||||
}
|
||||
|
||||
var isErrorGetter = containerCtrl.isErrorGetter || function() {
|
||||
return ngModelCtrl.$invalid && ngModelCtrl.$touched;
|
||||
};
|
||||
scope.$watch(isErrorGetter, containerCtrl.setInvalid);
|
||||
|
||||
ngModelCtrl.$parsers.push(ngModelPipelineCheckValue);
|
||||
ngModelCtrl.$formatters.push(ngModelPipelineCheckValue);
|
||||
|
||||
element.on('input', inputCheckValue);
|
||||
|
||||
if (!isReadonly) {
|
||||
element
|
||||
.on('focus', function(ev) {
|
||||
containerCtrl.setFocused(true);
|
||||
})
|
||||
.on('blur', function(ev) {
|
||||
containerCtrl.setFocused(false);
|
||||
inputCheckValue();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//ngModelCtrl.$setTouched();
|
||||
//if( ngModelCtrl.$invalid ) containerCtrl.setInvalid();
|
||||
|
||||
scope.$on('$destroy', function() {
|
||||
containerCtrl.setFocused(false);
|
||||
containerCtrl.setHasValue(false);
|
||||
containerCtrl.input = null;
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function ngModelPipelineCheckValue(arg) {
|
||||
containerCtrl.setHasValue(!ngModelCtrl.$isEmpty(arg));
|
||||
return arg;
|
||||
}
|
||||
function inputCheckValue() {
|
||||
// An input's value counts if its length > 0,
|
||||
// or if the input's validity state says it has bad input (eg string in a number input)
|
||||
containerCtrl.setHasValue(element.val().length > 0 || (element[0].validity||{}).badInput);
|
||||
}
|
||||
|
||||
function setupTextarea() {
|
||||
var node = element[0];
|
||||
var onChangeTextarea = $mdUtil.debounce(growTextarea, 1);
|
||||
|
||||
function pipelineListener(value) {
|
||||
onChangeTextarea();
|
||||
return value;
|
||||
}
|
||||
|
||||
if (ngModelCtrl) {
|
||||
ngModelCtrl.$formatters.push(pipelineListener);
|
||||
ngModelCtrl.$viewChangeListeners.push(pipelineListener);
|
||||
} else {
|
||||
onChangeTextarea();
|
||||
}
|
||||
element.on('keydown input', onChangeTextarea);
|
||||
element.on('scroll', onScroll);
|
||||
angular.element($window).on('resize', onChangeTextarea);
|
||||
|
||||
scope.$on('$destroy', function() {
|
||||
angular.element($window).off('resize', onChangeTextarea);
|
||||
});
|
||||
|
||||
function growTextarea() {
|
||||
node.style.height = "auto";
|
||||
node.scrollTop = 0;
|
||||
var height = getHeight();
|
||||
if (height) node.style.height = height + 'px';
|
||||
}
|
||||
|
||||
function getHeight () {
|
||||
var line = node.scrollHeight - node.offsetHeight;
|
||||
return node.offsetHeight + (line > 0 ? line : 0);
|
||||
}
|
||||
|
||||
function onScroll(e) {
|
||||
node.scrollTop = 0;
|
||||
// for smooth new line adding
|
||||
var line = node.scrollHeight - node.offsetHeight;
|
||||
var height = node.offsetHeight + line;
|
||||
node.style.height = height + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inputTextareaDirective.$inject = ["$mdUtil", "$window", "$mdAria"];
|
||||
|
||||
function mdMaxlengthDirective($animate) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: ['ngModel', '^mdInputContainer'],
|
||||
link: postLink
|
||||
};
|
||||
|
||||
function postLink(scope, element, attr, ctrls) {
|
||||
var maxlength;
|
||||
var ngModelCtrl = ctrls[0];
|
||||
var containerCtrl = ctrls[1];
|
||||
var charCountEl = angular.element('<div class="md-char-counter">');
|
||||
|
||||
// Stop model from trimming. This makes it so whitespace
|
||||
// over the maxlength still counts as invalid.
|
||||
attr.$set('ngTrim', 'false');
|
||||
containerCtrl.element.append(charCountEl);
|
||||
|
||||
ngModelCtrl.$formatters.push(renderCharCount);
|
||||
ngModelCtrl.$viewChangeListeners.push(renderCharCount);
|
||||
element.on('input keydown', function() {
|
||||
renderCharCount(); //make sure it's called with no args
|
||||
});
|
||||
|
||||
scope.$watch(attr.mdMaxlength, function(value) {
|
||||
maxlength = value;
|
||||
if (angular.isNumber(value) && value > 0) {
|
||||
if (!charCountEl.parent().length) {
|
||||
$animate.enter(charCountEl, containerCtrl.element,
|
||||
angular.element(containerCtrl.element[0].lastElementChild));
|
||||
}
|
||||
renderCharCount();
|
||||
} else {
|
||||
$animate.leave(charCountEl);
|
||||
}
|
||||
});
|
||||
|
||||
ngModelCtrl.$validators['md-maxlength'] = function(modelValue, viewValue) {
|
||||
if (!angular.isNumber(maxlength) || maxlength < 0) {
|
||||
return true;
|
||||
}
|
||||
return ( modelValue || element.val() || viewValue || '' ).length <= maxlength;
|
||||
};
|
||||
|
||||
function renderCharCount(value) {
|
||||
charCountEl.text( ( element.val() || value || '' ).length + '/' + maxlength );
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
mdMaxlengthDirective.$inject = ["$animate"];
|
||||
|
||||
function placeholderDirective($log) {
|
||||
var blackListElements = ['MD-SELECT'];
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: '^^?mdInputContainer',
|
||||
priority: 200,
|
||||
link: postLink
|
||||
};
|
||||
|
||||
function postLink(scope, element, attr, inputContainer) {
|
||||
if (!inputContainer) return;
|
||||
if (blackListElements.indexOf(element[0].nodeName) != -1) return;
|
||||
if (angular.isDefined(inputContainer.element.attr('md-no-float'))) return;
|
||||
|
||||
var placeholderText = attr.placeholder;
|
||||
element.removeAttr('placeholder');
|
||||
|
||||
if ( inputContainer.element.find('label').length == 0 ) {
|
||||
var placeholder = '<label ng-click="delegateClick()">' + placeholderText + '</label>';
|
||||
|
||||
inputContainer.element.addClass('md-icon-float');
|
||||
inputContainer.element.prepend(placeholder);
|
||||
} else {
|
||||
$log.warn("The placeholder='" + placeholderText + "' will be ignored since this md-input-container has a child label element.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
placeholderDirective.$inject = ["$log"];
|
||||
|
||||
ng.material.components.input = angular.module("material.components.input");
|
||||
Reference in New Issue
Block a user