Neues Initialrelease mit IonicMaterial

This commit is contained in:
Carsten Hilmer
2016-08-22 12:55:52 +02:00
parent 30a5df79aa
commit 45e482b14d
1249 changed files with 305225 additions and 68794 deletions

View File

@@ -0,0 +1,7 @@
{
"name": "angular-material-input",
"version": "0.10.0",
"dependencies": {
"angular-material-core": "0.10.0"
}
}

View File

@@ -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%); }

View File

@@ -0,0 +1,6 @@
/*!
* Angular Material Design
* https://github.com/angular/material
* @license MIT
* v0.10.0
*/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:-moz-placeholder,md-input-container.md-THEME_NAME-theme .md-input:-ms-input-placeholder,md-input-container.md-THEME_NAME-theme .md-input::-moz-placeholder,md-input-container.md-THEME_NAME-theme .md-input::-webkit-input-placeholder{color:'{{foreground-3}}'}md-input-container.md-THEME_NAME-theme>md-icon{color:'{{foreground-1}}'}md-input-container.md-THEME_NAME-theme .md-placeholder,md-input-container.md-THEME_NAME-theme label{text-shadow:'{{foreground-shadow}}';color:'{{foreground-3}}'}md-input-container.md-THEME_NAME-theme [data-ng-message],md-input-container.md-THEME_NAME-theme [ng-message],md-input-container.md-THEME_NAME-theme [x-ng-message],md-input-container.md-THEME_NAME-theme ng-messages{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,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-char-counter,md-input-container.md-THEME_NAME-theme.md-input-invalid [data-ng-message],md-input-container.md-THEME_NAME-theme.md-input-invalid [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 data-ng-message,md-input-container.md-THEME_NAME-theme.md-input-invalid 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-input-focused label{color:'{{warn-500}}'}[disabled] md-input-container.md-THEME_NAME-theme .md-input,md-input-container.md-THEME_NAME-theme .md-input[disabled]{border-bottom-color:transparent;color:'{{foreground-3}}';background-image:linear-gradient(to right,'{{foreground-3}}' 0,'{{foreground-3}}' 33%,transparent 0)}

View 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; } }

View File

@@ -0,0 +1,372 @@
/*!
* Angular Material Design
* https://github.com/angular/material
* @license MIT
* v0.10.0
*/
(function( window, angular, undefined ){
"use strict";
/**
* @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"];
})(window, window.angular);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
/*!
* Angular Material Design
* https://github.com/angular/material
* @license MIT
* v0.10.0
*/
!function(e,t,n){"use strict";function i(e,t){function n(t,n,i){e(n)}function i(e,n,i){var r=this;r.isErrorGetter=i.mdIsError&&t(i.mdIsError),r.delegateClick=function(){r.input.focus()},r.element=n,r.setFocused=function(e){n.toggleClass("md-input-focused",!!e)},r.setHasValue=function(e){n.toggleClass("md-input-has-value",!!e)},r.setInvalid=function(e){n.toggleClass("md-input-invalid",!!e)},e.$watch(function(){return r.label&&r.input},function(e){e&&!r.label.attr("for")&&r.label.attr("for",r.input.attr("id"))})}return i.$inject=["$scope","$element","$attrs"],{restrict:"E",link:n,controller:i}}function r(){return{restrict:"E",require:"^?mdInputContainer",link:function(e,t,n,i){i&&!n.mdNoFloat&&(i.label=t,e.$on("$destroy",function(){i.label=null}))}}}function l(e,n,i){function r(r,l,o,a){function u(e){return d.setHasValue(!f.$isEmpty(e)),e}function s(){d.setHasValue(l.val().length>0||(l[0].validity||{}).badInput)}function c(){function i(e){return c(),e}function o(){s.style.height="auto",s.scrollTop=0;var e=a();e&&(s.style.height=e+"px")}function a(){var e=s.scrollHeight-s.offsetHeight;return s.offsetHeight+(e>0?e:0)}function u(e){s.scrollTop=0;var t=s.scrollHeight-s.offsetHeight,n=s.offsetHeight+t;s.style.height=n+"px"}var s=l[0],c=e.debounce(o,1);f?(f.$formatters.push(i),f.$viewChangeListeners.push(i)):c(),l.on("keydown input",c),l.on("scroll",u),t.element(n).on("resize",c),r.$on("$destroy",function(){t.element(n).off("resize",c)})}var d=a[0],f=a[1]||e.fakeNgModel(),m=t.isDefined(o.readonly);if(d){if(d.input)throw new Error("<md-input-container> can only have *one* <input> or <textarea> child element!");d.input=l,d.label||i.expect(l,"aria-label",l.attr("placeholder")),l.addClass("md-input"),l.attr("id")||l.attr("id","input_"+e.nextUid()),"textarea"===l[0].tagName.toLowerCase()&&c();var p=d.isErrorGetter||function(){return f.$invalid&&f.$touched};r.$watch(p,d.setInvalid),f.$parsers.push(u),f.$formatters.push(u),l.on("input",s),m||l.on("focus",function(e){d.setFocused(!0)}).on("blur",function(e){d.setFocused(!1),s()}),r.$on("$destroy",function(){d.setFocused(!1),d.setHasValue(!1),d.input=null})}}return{restrict:"E",require:["^?mdInputContainer","?ngModel"],link:r}}function o(e){function n(n,i,r,l){function o(e){return c.text((i.val()||e||"").length+"/"+a),e}var a,u=l[0],s=l[1],c=t.element('<div class="md-char-counter">');r.$set("ngTrim","false"),s.element.append(c),u.$formatters.push(o),u.$viewChangeListeners.push(o),i.on("input keydown",function(){o()}),n.$watch(r.mdMaxlength,function(n){a=n,t.isNumber(n)&&n>0?(c.parent().length||e.enter(c,s.element,t.element(s.element[0].lastElementChild)),o()):e.leave(c)}),u.$validators["md-maxlength"]=function(e,n){return!t.isNumber(a)||0>a?!0:(e||i.val()||n||"").length<=a}}return{restrict:"A",require:["ngModel","^mdInputContainer"],link:n}}function a(e){function n(n,r,l,o){if(o&&-1==i.indexOf(r[0].nodeName)&&!t.isDefined(o.element.attr("md-no-float"))){var a=l.placeholder;if(r.removeAttr("placeholder"),0==o.element.find("label").length){var u='<label ng-click="delegateClick()">'+a+"</label>";o.element.addClass("md-icon-float"),o.element.prepend(u)}else e.warn("The placeholder='"+a+"' will be ignored since this md-input-container has a child label element.")}}var i=["MD-SELECT"];return{restrict:"A",require:"^^?mdInputContainer",priority:200,link:n}}t.module("material.components.input",["material.core"]).directive("mdInputContainer",i).directive("label",r).directive("input",l).directive("textarea",l).directive("mdMaxlength",o).directive("placeholder",a),i.$inject=["$mdTheming","$parse"],l.$inject=["$mdUtil","$window","$mdAria"],o.$inject=["$animate"],a.$inject=["$log"]}(window,window.angular);