forked from muicss/mui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcol.js
More file actions
50 lines (41 loc) · 1.25 KB
/
col.js
File metadata and controls
50 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* MUI Angular Col (Grid) Component
* @module angular/col
*/
import angular from 'angular';
const moduleName = 'mui.col';
angular.module(moduleName, [])
.directive('muiCol', function() {
return {
restrict: 'AE',
scope: true,
replace: true,
template: '<div></div>',
transclude: true,
link: function(scope, element, attrs, controller, transcludeFn) {
// use transcludeFn to pass ng-controller on parent element
transcludeFn(scope, function(clone) {
element.append(clone);
});
// iterate through breakpoints
var breakpoints = {
'xs': 'mui-col-xs-',
'sm': 'mui-col-sm-',
'md': 'mui-col-md-',
'lg': 'mui-col-lg-',
'xl': 'mui-col-xl-',
'xs-offset': 'mui-col-xs-offset-',
'sm-offset': 'mui-col-sm-offset-',
'md-offset': 'mui-col-md-offset-',
'lg-offset': 'mui-col-lg-offset-',
'xl-offset': 'mui-col-xl-offset-'
};
angular.forEach(breakpoints, function(value, key) {
var attrVal = attrs[attrs.$normalize(key)];
if (attrVal) element.addClass(value + attrVal);
})
}
}
});
/** Define module API */
export default moduleName;