Skip to content

Commit 12bfdcf

Browse files
committed
adding component directive
1 parent 8f93c02 commit 12bfdcf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎scripts/directives/component.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
angular.module('angularBootstrapMaterial')
2+
.directive('abmComponent', ['ripple', function (ripple) {
3+
return {
4+
link: function ($scope, $element, attrs) {
5+
var componentMap = {
6+
".btn:not(.btn-link)": "",
7+
".card-image": "",
8+
".navbar": "a:not(.withoutripple)",
9+
".dropdown-menu": "a",
10+
".nav-tabs": "a:not(.withoutripple)",
11+
".withripple": "",
12+
".pagination": "li:not(.active):not(.disabled) a:not(.withoutripple)"
13+
};
14+
var matches = null;
15+
//check if the element
16+
$parent = $element.parent();
17+
for (var key in componentMap) {
18+
if (componentMap.hasOwnProperty(key)) {
19+
var value = componentMap[key];
20+
if (matches) break;
21+
var elems = $parent[0].querySelectorAll(key);
22+
for (var i = 0; i < elems.length; i++) {
23+
var elem = elems[i];
24+
if (elem === $element[0]) {
25+
if (value)
26+
matches = elem.querySelectorAll(value);
27+
else
28+
matches = elem;
29+
break;
30+
}
31+
}
32+
}
33+
}
34+
angular.forEach(matches, function (elem) {
35+
ripple(angular.element(elem));
36+
});
37+
}
38+
};
39+
}]);

0 commit comments

Comments
 (0)