diff --git a/.gitignore b/.gitignore
index f76d116eca6..02ae8b3d37f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,6 @@ dist
/vendor
.polymer-qp
+
+atlassian-ide-plugin.xml
+*.iml
diff --git a/src/components/textField/demoBasicUsage/index.html b/src/components/textField/demoBasicUsage/index.html
index 8b9f5d01faa..cd158978519 100644
--- a/src/components/textField/demoBasicUsage/index.html
+++ b/src/components/textField/demoBasicUsage/index.html
@@ -1,28 +1,28 @@
-
diff --git a/src/components/textField/demoBasicUsage/script.js b/src/components/textField/demoBasicUsage/script.js
index 9faf8685ee8..c0eb7974dba 100644
--- a/src/components/textField/demoBasicUsage/script.js
+++ b/src/components/textField/demoBasicUsage/script.js
@@ -1,22 +1,22 @@
-
angular.module('textFieldDemo1', ['ngMaterial'])
- /**
- * Simple controller to build a `user` data model
- * that will be used to databinding with `
` directives
- */
- .controller('DemoController', function($scope) {
+/**
+ * Simple controller to build a `user` data model
+ * that will be used to databinding with `` directives
+ */
+ .controller('DemoController', function ($scope) {
$scope.user = {
- title: "Technical Program Manager",
- email: "ipsum@lorem.com",
- firstName: "Naomi",
- lastName: "" ,
- company: "Google" ,
- address: "1600 Amphitheatre Pkwy" ,
- city: "Mountain View" ,
- state: "CA" ,
- country: "USA" ,
- postalCode : "94043"
+ title: "Technical Program Manager",
+ email: "ipsum@lorem.com",
+ firstName: "Naomi",
+ lastName: "",
+ company: "Google",
+ address: "1600 Amphitheatre Pkwy",
+ city: "Mountain View",
+ state: "CA",
+ country: "USA",
+ postalCode: "94043",
+ intro: ""
};
});
diff --git a/src/components/textField/textField.js b/src/components/textField/textField.js
index 79136bb00c1..10d1118c564 100644
--- a/src/components/textField/textField.js
+++ b/src/components/textField/textField.js
@@ -5,10 +5,11 @@
* Form
*/
angular.module('material.components.textField', ['material.core', 'material.services.theming'])
- .directive('mdInputGroup', [ mdInputGroupDirective ])
- .directive('mdInput', ['$mdUtil', mdInputDirective ])
- .directive('mdTextFloat', [ '$mdTheming', '$mdUtil', mdTextFloatDirective ]);
-
+ .directive('mdInputGroup', [ mdInputGroupDirective ])
+ .directive('mdInput', ['$mdUtil', mdInputDirective ])
+ .directive('mdTextarea', ['$mdUtil', mdTextareaDirective])
+ .directive('mdTextFloat', [ '$mdTheming', '$mdUtil', mdTextFloatDirective ])
+ .directive('mdTextareaFloat', [ '$mdTheming', '$mdUtil', mdTextareaFloatDirective ]);
/**
@@ -41,21 +42,21 @@ function mdTextFloatDirective($mdTheming, $mdUtil) {
return {
restrict: 'E',
replace: true,
- scope : {
- fid : '@?',
- label : '@?',
- value : '=ngModel'
+ scope: {
+ fid: '@?',
+ label: '@?',
+ value: '=ngModel'
},
- compile : function(element, attr) {
+ compile: function (element, attr) {
- if ( angular.isUndefined(attr.fid) ) {
+ if (angular.isUndefined(attr.fid)) {
attr.fid = $mdUtil.nextUid();
}
return {
- pre : function(scope, element, attrs) {
+ pre: function (scope, element, attrs) {
// transpose `disabled` flag
- if ( angular.isDefined(attrs.disabled) ) {
+ if (angular.isDefined(attrs.disabled)) {
element.attr('disabled', true);
scope.isDisabled = true;
}
@@ -64,17 +65,80 @@ function mdTextFloatDirective($mdTheming, $mdUtil) {
element.removeAttr('type');
// transpose optional `class` settings
- element.attr('class', attrs.class );
+ element.attr('class', attrs.class);
+
+ },
+ post: $mdTheming
+ };
+ },
+ template: '' +
+ ' ' +
+ ' ' +
+ ''
+ };
+}
+
+/**
+ * @ngdoc directive
+ * @name mdTextareaFloat
+ * @module material.components.textField
+ *
+ * @restrict E
+ *
+ * @description
+ * Use the `` directive to quickly construct `Floating Label` textarea fields
+ *
+ * @param {string} fid Attribute used for accessibility link pairing between the Label and Input elements
+ * @param {string=} rows Optional value to define the amount of rows.
+ * @param {string=} cols Optional value to define the amount of cols.
+ * @param {string} label Attribute to specify the input text field hint.
+ * @param {string=} ng-model Optional value to assign as existing input text string
+ *
+ * @usage
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+function mdTextareaFloatDirective($mdTheming, $mdUtil) {
+ return {
+ restrict: 'E',
+ replace: true,
+ scope: {
+ fid: '@?',
+ label: '@?',
+ rows: '@?',
+ cols: '@?',
+ value: '=ngModel'
+ },
+ compile: function (element, attr) {
+
+ if (angular.isUndefined(attr.fid)) {
+ attr.fid = $mdUtil.nextUid();
+ }
+
+ return {
+ pre: function (scope, element, attrs) {
+ // transpose `disabled` flag
+ if (angular.isDefined(attrs.disabled)) {
+ element.attr('disabled', true);
+ scope.isDisabled = true;
+ }
+
+ // transpose optional `class` settings
+ element.attr('class', attrs.class);
},
post: $mdTheming
};
},
- template:
- '' +
- ' ' +
- ' ' +
- ''
+ template: '' +
+ ' ' +
+ ' ' +
+ ''
};
}
@@ -99,12 +163,12 @@ function mdTextFloatDirective($mdTheming, $mdUtil) {
function mdInputGroupDirective() {
return {
restrict: 'CE',
- controller: ['$element', function($element) {
- this.setFocused = function(isFocused) {
+ controller: ['$element', function ($element) {
+ this.setFocused = function (isFocused) {
$element.toggleClass('md-input-focused', !!isFocused);
};
- this.setHasValue = function(hasValue) {
- $element.toggleClass('md-input-has-value', hasValue );
+ this.setHasValue = function (hasValue) {
+ $element.toggleClass('md-input-has-value', hasValue);
};
}]
};
@@ -137,59 +201,111 @@ function mdInputDirective($mdUtil) {
replace: true,
template: '',
require: ['^?mdInputGroup', '?ngModel'],
- link: function(scope, element, attr, ctrls) {
- var inputGroupCtrl = ctrls[0];
- var ngModelCtrl = ctrls[1];
- if (!inputGroupCtrl) {
- return;
- }
+ link: function mdInputDirectiveLink(scope, element, attr, ctrls) {
+ linkBehaviours(scope, element, ctrls, $mdUtil);
- // scan for disabled and transpose the `type` value to the element
- var isDisabled = $mdUtil.isParentDisabled(element);
-
- element.attr('tabindex', isDisabled ? -1 : 0 );
- element.attr('aria-disabled', isDisabled ? 'true' : 'false');
- element.attr('type', attr.type || element.parent().attr('type') || "text" );
-
- // When the input value changes, check if it "has" a value, and
- // set the appropriate class on the input group
- if (ngModelCtrl) {
- //Add a $formatter so we don't use up the render function
- ngModelCtrl.$formatters.push(function(value) {
- inputGroupCtrl.setHasValue( isNotEmpty(value) );
- return value;
- });
- }
+ element.attr('type', attr.type || element.parent().attr('type') || "text");
+ }
+ };
+}
- element.on('input', function() {
- inputGroupCtrl.setHasValue( isNotEmpty() );
- });
-
- // When the input focuses, add the focused class to the group
- element.on('focus', function(e) {
- inputGroupCtrl.setFocused(true);
- });
- // When the input blurs, remove the focused class from the group
- element.on('blur', function(e) {
- inputGroupCtrl.setFocused(false);
- inputGroupCtrl.setHasValue( isNotEmpty() );
- });
-
- scope.$on('$destroy', function() {
- inputGroupCtrl.setFocused(false);
- inputGroupCtrl.setHasValue(false);
- });
-
-
- function isNotEmpty(value) {
- value = angular.isUndefined(value) ? element.val() : value;
- return (angular.isDefined(value) && (value!==null) &&
- (value.toString().trim() != ""));
- }
+/*
+ * @private
+ *
+ * @ngdoc directive
+ * @name mdTextarea
+ * @module material.components.textField
+ *
+ * @restrict E
+ *
+ * @description
+ * Use the `` directive as elements within a `` container
+ *
+ * @usage
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+function mdTextareaDirective($mdUtil) {
+ return {
+ restrict: 'E',
+ replace: true,
+ template: ' '
};
/**
* Build a text float group using the `` markup template
*/
function setupInputGroup(expressions, values) {
- values = angular.extend({},{type:"text", id:''},values||{});
+ values = angular.extend({}, {type: "text", id: ''}, values || {});
- return buildElement( templates.md_input_group, values, angular.extend({}, expressions||{}));
+ return buildElement(templates.md_input_group, values, angular.extend({}, expressions || {}));
}
/**
* Build a text float group using the `` markup template
*/
function setupTextFloat(expressions, values) {
- values = angular.extend({ modelValue:"",type:'text' }, values || {});
+ values = angular.extend({ modelValue: "", type: 'text' }, values || {});
- var defaults = {model:"modelValue", label:""};
- var tokens = angular.extend({}, defaults, expressions||{} );
+ var defaults = {model: "modelValue", label: ""};
+ var tokens = angular.extend({}, defaults, expressions || {});
- return buildElement( templates.md_text_float, values, tokens );
+ return buildElement(templates.md_text_float, values, tokens);
}
/**
@@ -269,19 +312,19 @@ describe('Text Field directives', function() {
* and link both the bindings and attribute assignments.
* @returns {*} DOM Element
*/
- function buildElement( template, scope, interpolationScope ) {
+ function buildElement(template, scope, interpolationScope) {
var el;
- inject(function($compile, $interpolate, $rootScope) {
- scope = angular.extend( $rootScope.$new(), scope || {});
+ inject(function ($compile, $interpolate, $rootScope) {
+ scope = angular.extend($rootScope.$new(), scope || {});
// First substitute interpolation values into the template... if any
- if ( interpolationScope ) {
- template = $interpolate( template )( interpolationScope );
+ if (interpolationScope) {
+ template = $interpolate(template)(interpolationScope);
}
// Compile the template using the scope model(s)
- el = $compile( template )( scope );
+ el = $compile(template)(scope);
$rootScope.$apply();
});