|
1 |
| - angular |
2 |
| - .module('material.components.chips') |
3 |
| - .directive('mdContactChips', MdContactChips); |
| 1 | +angular |
| 2 | + .module('material.components.chips') |
| 3 | + .directive('mdContactChips', MdContactChips); |
4 | 4 |
|
5 |
| - /** |
6 |
| - * @ngdoc directive |
7 |
| - * @name mdContactChips |
8 |
| - * @module material.components.chips |
9 |
| - * |
10 |
| - * @description |
11 |
| - * `<md-contact-chips>` is an input component based on `md-chips` and makes use of an |
12 |
| - * `md-autocomplete` element. The component allows the caller to supply a query expression |
13 |
| - * which returns a list of possible contacts. The user can select one of these and add it to |
14 |
| - * the list of chips. |
15 |
| - * |
16 |
| - * @param {string=|object=} ng-model A model to bind the list of items to |
17 |
| - * @param {string=} placeholder Placeholder text that will be forwarded to the input. |
18 |
| - * @param {string=} secondary-placeholder Placeholder text that will be forwarded to the input, |
19 |
| - * displayed when there is at least on item in the list |
20 |
| - * @param {expression} md-contacts An expression expected to return contacts matching the search |
21 |
| - * test, `$query`. |
22 |
| - * @param {string} md-contact-name The field name of the contact object representing the |
23 |
| - * contact's name. |
24 |
| - * @param {string} md-contact-email The field name of the contact object representing the |
25 |
| - * contact's email address. |
26 |
| - * @param {string} md-contact-image The field name of the contact object representing the |
27 |
| - * contact's image. |
28 |
| - * |
29 |
| - * |
30 |
| - * // The following attribute has been removed but may come back. |
31 |
| - * @param {expression=} filter-selected Whether to filter selected contacts from the list of |
32 |
| - * suggestions shown in the autocomplete. |
33 |
| - * |
34 |
| - * |
35 |
| - * |
36 |
| - * @usage |
37 |
| - * <hljs lang="html"> |
38 |
| - * <md-contact-chips |
39 |
| - * ng-model="ctrl.contacts" |
40 |
| - * md-contacts="ctrl.querySearch($query)" |
41 |
| - * md-contact-name="name" |
42 |
| - * md-contact-image="image" |
43 |
| - * md-contact-email="email" |
44 |
| - * placeholder="To"> |
45 |
| - * </md-contact-chips> |
46 |
| - * </hljs> |
47 |
| - * |
48 |
| - */ |
| 5 | +/** |
| 6 | + * @ngdoc directive |
| 7 | + * @name mdContactChips |
| 8 | + * @module material.components.chips |
| 9 | + * |
| 10 | + * @description |
| 11 | + * `<md-contact-chips>` is an input component based on `md-chips` and makes use of an |
| 12 | + * `md-autocomplete` element. The component allows the caller to supply a query expression which |
| 13 | + * returns a list of possible contacts. The user can select one of these and add it to the list of |
| 14 | + * chips. |
| 15 | + * |
| 16 | + * You may also use the `md-highlight-text` directive along with it's parameters to control the |
| 17 | + * appearance of the matched text inside of the contacts' autocomplete popup. |
| 18 | + * |
| 19 | + * @param {string=|object=} ng-model A model to bind the list of items to |
| 20 | + * @param {string=} placeholder Placeholder text that will be forwarded to the input. |
| 21 | + * @param {string=} secondary-placeholder Placeholder text that will be forwarded to the input, |
| 22 | + * displayed when there is at least on item in the list |
| 23 | + * @param {expression} md-contacts An expression expected to return contacts matching the search |
| 24 | + * test, `$query`. |
| 25 | + * @param {string} md-contact-name The field name of the contact object representing the |
| 26 | + * contact's name. |
| 27 | + * @param {string} md-contact-email The field name of the contact object representing the |
| 28 | + * contact's email address. |
| 29 | + * @param {string} md-contact-image The field name of the contact object representing the |
| 30 | + * contact's image. |
| 31 | + * |
| 32 | + * |
| 33 | + * // The following attribute has been removed but may come back. |
| 34 | + * @param {expression=} filter-selected Whether to filter selected contacts from the list of |
| 35 | + * suggestions shown in the autocomplete. |
| 36 | + * |
| 37 | + * |
| 38 | + * |
| 39 | + * @usage |
| 40 | + * <hljs lang="html"> |
| 41 | + * <md-contact-chips |
| 42 | + * ng-model="ctrl.contacts" |
| 43 | + * md-contacts="ctrl.querySearch($query)" |
| 44 | + * md-contact-name="name" |
| 45 | + * md-contact-image="image" |
| 46 | + * md-contact-email="email" |
| 47 | + * placeholder="To"> |
| 48 | + * </md-contact-chips> |
| 49 | + * </hljs> |
| 50 | + * |
| 51 | + */ |
49 | 52 |
|
50 | 53 |
|
51 |
| - var MD_CONTACT_CHIPS_TEMPLATE = '\ |
| 54 | +var MD_CONTACT_CHIPS_TEMPLATE = '\ |
52 | 55 | <md-chips class="md-contact-chips"\
|
53 | 56 | ng-model="$mdContactChipsCtrl.contacts"\
|
54 | 57 | md-require-match="$mdContactChipsCtrl.requireMatch"\
|
|
67 | 70 | <img \
|
68 | 71 | ng-src="{{item[$mdContactChipsCtrl.contactImage]}}"\
|
69 | 72 | alt="{{item[$mdContactChipsCtrl.contactName]}}" />\
|
70 |
| - <span class="md-contact-name" md-highlight-text="$mdContactChipsCtrl.searchText">\ |
| 73 | + <span class="md-contact-name" md-highlight-text="$mdContactChipsCtrl.searchText"\ |
| 74 | + md-highlight-flags="{{$mdContactChipsCtrl.highlightFlags}}">\ |
71 | 75 | {{item[$mdContactChipsCtrl.contactName]}}\
|
72 | 76 | </span>\
|
73 | 77 | <span class="md-contact-email" >{{item[$mdContactChipsCtrl.contactEmail]}}</span>\
|
|
86 | 90 | </md-chips>';
|
87 | 91 |
|
88 | 92 |
|
89 |
| - /** |
90 |
| - * MDContactChips Directive Definition |
91 |
| - * |
92 |
| - * @param $mdTheming |
93 |
| - * @returns {*} |
94 |
| - * @ngInject |
95 |
| - */ |
96 |
| - function MdContactChips ($mdTheming, $mdUtil) { |
97 |
| - return { |
98 |
| - template: function(element, attrs) { |
99 |
| - return MD_CONTACT_CHIPS_TEMPLATE; |
100 |
| - }, |
101 |
| - restrict: 'E', |
102 |
| - controller: 'MdContactChipsCtrl', |
103 |
| - controllerAs: '$mdContactChipsCtrl', |
104 |
| - bindToController: true, |
105 |
| - compile: compile, |
106 |
| - scope: { |
107 |
| - contactQuery: '&mdContacts', |
108 |
| - placeholder: '@', |
109 |
| - secondaryPlaceholder: '@', |
110 |
| - contactName: '@mdContactName', |
111 |
| - contactImage: '@mdContactImage', |
112 |
| - contactEmail: '@mdContactEmail', |
113 |
| - contacts: '=ngModel', |
114 |
| - requireMatch: '=?mdRequireMatch' |
115 |
| - } |
116 |
| - }; |
| 93 | +/** |
| 94 | + * MDContactChips Directive Definition |
| 95 | + * |
| 96 | + * @param $mdTheming |
| 97 | + * @returns {*} |
| 98 | + * @ngInject |
| 99 | + */ |
| 100 | +function MdContactChips($mdTheming, $mdUtil) { |
| 101 | + return { |
| 102 | + template: function(element, attrs) { |
| 103 | + return MD_CONTACT_CHIPS_TEMPLATE; |
| 104 | + }, |
| 105 | + restrict: 'E', |
| 106 | + controller: 'MdContactChipsCtrl', |
| 107 | + controllerAs: '$mdContactChipsCtrl', |
| 108 | + bindToController: true, |
| 109 | + compile: compile, |
| 110 | + scope: { |
| 111 | + contactQuery: '&mdContacts', |
| 112 | + placeholder: '@', |
| 113 | + secondaryPlaceholder: '@', |
| 114 | + contactName: '@mdContactName', |
| 115 | + contactImage: '@mdContactImage', |
| 116 | + contactEmail: '@mdContactEmail', |
| 117 | + contacts: '=ngModel', |
| 118 | + requireMatch: '=?mdRequireMatch', |
| 119 | + highlightFlags: '@?mdHighlightFlags' |
| 120 | + } |
| 121 | + }; |
117 | 122 |
|
118 |
| - function compile(element, attr) { |
119 |
| - return function postLink(scope, element, attrs, controllers) { |
| 123 | + function compile(element, attr) { |
| 124 | + return function postLink(scope, element, attrs, controllers) { |
120 | 125 |
|
121 |
| - $mdUtil.initOptionalProperties(scope, attr); |
122 |
| - $mdTheming(element); |
| 126 | + $mdUtil.initOptionalProperties(scope, attr); |
| 127 | + $mdTheming(element); |
123 | 128 |
|
124 |
| - element.attr('tabindex', '-1'); |
125 |
| - }; |
126 |
| - } |
| 129 | + element.attr('tabindex', '-1'); |
| 130 | + }; |
127 | 131 | }
|
| 132 | +} |
0 commit comments