Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Commit

Permalink
style: SWAG
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela committed Dec 17, 2015
1 parent f589ce6 commit e61a24a
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 213 deletions.
28 changes: 14 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import types from './types';
const ngModuleName = 'formlyMaterial';

angular.module(ngModuleName, [
'ngMessages',
'ngMaterial',
'formly'
])
.config(['formlyConfigProvider', (formlyConfigProvider) => {
const configs = [runs, wrappers, types];
'ngMessages',
'ngMaterial',
'formly'
])
.config(['formlyConfigProvider', (formlyConfigProvider) => {
const configs = [runs, wrappers, types];

configs.forEach((config) => {
let i = 0;
for (; i < config.length; i++) {
config[i](formlyConfigProvider);
}
});
}]);
configs.forEach((config) => {
let i = 0;
for (; i < config.length; i++) {
config[i](formlyConfigProvider);
}
});
}]);

export default ngModuleName;
export default ngModuleName;
7 changes: 5 additions & 2 deletions src/runs/md-no-autogrow.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import {ngModelAttrsManipulator} from './../helpers/index.js';
import {
ngModelAttrsManipulator
}
from './../helpers/index.js';

export default (formlyConfigProvider) => {
formlyConfigProvider.templateManipulators.preWrapper.push((template, options) => {
if (!angular.isDefined(options.templateOptions.grow)) {
return template;
}
if(options.templateOptions.grow !== false) {
if (options.templateOptions.grow !== false) {
return template;
}
if (!angular.isDefined(options.type) || options.type !== 'textarea') {
Expand Down
5 changes: 4 additions & 1 deletion src/runs/md-theme-manipulator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {ngModelAttrsManipulator} from './../helpers/index.js';
import {
ngModelAttrsManipulator
}
from './../helpers/index.js';

export default (formlyConfigProvider) => {
formlyConfigProvider.templateManipulators.preWrapper.push((template, options) => {
Expand Down
10 changes: 5 additions & 5 deletions src/types/checkbox/checkbox.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import template from './checkbox.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'checkbox',
template: template
});
}
formlyConfigProvider.setType({
name: 'checkbox',
template: template
});
}
50 changes: 29 additions & 21 deletions src/types/chips/chips.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import template from './chips.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'chips',
template: template,
defaultOptions: {
defaultValue: [],
ngModelAttrs: {
placeholder: {attribute: 'placeholder'},
secondaryPlaceholder: {attribute: 'secondary-placeholder'},
deleteButtonLabel: {attribute: 'delete-button-label'},
deleteHint: {attribute: 'delete-hint'}
}
formlyConfigProvider.setType({
name: 'chips',
template: template,
defaultOptions: {
defaultValue: [],
ngModelAttrs: {
placeholder: {
attribute: 'placeholder'
},
apiCheck: (check) => ({
templateOptions: {
placeholder: check.string.optional,
secondaryPlaceholder: check.string.optional,
deleteButtonLabel: check.string.optional,
deleteHint: check.string.optional
}
})
});
}
secondaryPlaceholder: {
attribute: 'secondary-placeholder'
},
deleteButtonLabel: {
attribute: 'delete-button-label'
},
deleteHint: {
attribute: 'delete-hint'
}
}
},
apiCheck: (check) => ({
templateOptions: {
placeholder: check.string.optional,
secondaryPlaceholder: check.string.optional,
deleteButtonLabel: check.string.optional,
deleteHint: check.string.optional
}
})
});
}
58 changes: 29 additions & 29 deletions src/types/datepicker/datepicker.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import template from './datepicker.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'datepicker',
template: template,
wrapper: ['messages'],
defaultOptions: {
ngModelAttrs: {
placeholder: {
attribute: 'md-placeholder'
},
minDate: {
bound: 'md-min-date'
},
maxDate: {
bound: 'md-max-date'
},
filterDate: {
bound: 'md-date-filter'
}
}
formlyConfigProvider.setType({
name: 'datepicker',
template: template,
wrapper: ['messages'],
defaultOptions: {
ngModelAttrs: {
placeholder: {
attribute: 'md-placeholder'
},
apiCheck: (check) => ({
templateOptions: {
placeholder: check.string.optional,
minDate: check.instanceOf(Date).optional,
maxDate: check.instanceOf(Date).optional,
filterDate: check.func.optional
}
})
});
}
minDate: {
bound: 'md-min-date'
},
maxDate: {
bound: 'md-max-date'
},
filterDate: {
bound: 'md-date-filter'
}
}
},
apiCheck: (check) => ({
templateOptions: {
placeholder: check.string.optional,
minDate: check.instanceOf(Date).optional,
maxDate: check.instanceOf(Date).optional,
filterDate: check.func.optional
}
})
});
}
20 changes: 10 additions & 10 deletions src/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import switchType from './switch/switch';
import textareaType from './textarea/textarea';

export default [
checkboxType,
chipsType,
datepickerType,
inputType,
radioType,
selectType,
sliderType,
switchType,
textareaType
];
checkboxType,
chipsType,
datepickerType,
inputType,
radioType,
selectType,
sliderType,
switchType,
textareaType
];
24 changes: 12 additions & 12 deletions src/types/input/input.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import template from './input.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'input',
template: template,
wrapper: ['label', 'messages', 'inputContainer'],
defaultOptions: {
ngModelAttrs: {
mdMaxlength: {
bound: 'md-maxlength'
}
}
formlyConfigProvider.setType({
name: 'input',
template: template,
wrapper: ['label', 'messages', 'inputContainer'],
defaultOptions: {
ngModelAttrs: {
mdMaxlength: {
bound: 'md-maxlength'
}
});
}
}
}
});
}
24 changes: 12 additions & 12 deletions src/types/radio/radio.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import template from './radio.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'radio',
template: template,
apiCheck: (check) => ({
templateOptions: {
options: check.arrayOf(check.object),
labelProp: check.string.optional,
valueProp: check.string.optional
}
})
});
}
formlyConfigProvider.setType({
name: 'radio',
template: template,
apiCheck: (check) => ({
templateOptions: {
options: check.arrayOf(check.object),
labelProp: check.string.optional,
valueProp: check.string.optional
}
})
});
}
48 changes: 27 additions & 21 deletions src/types/select/select.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import template from './select.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'select',
template: template,
wrapper: ['label', 'messages', 'inputContainer'],
defaultOptions: {
ngModelAttrs: {
multiple: {bound: 'multiple'},
onClose: {bound: 'md-on-close'},
onOpen: {bound: 'md-on-open'}
}
formlyConfigProvider.setType({
name: 'select',
template: template,
wrapper: ['label', 'messages', 'inputContainer'],
defaultOptions: {
ngModelAttrs: {
multiple: {
bound: 'multiple'
},
apiCheck: (check) => ({
templateOptions: {
options: check.arrayOf(check.object),
multiple: check.bool.optional,
labelProp: check.string.optional,
valueProp: check.string.optional,
onClose: check.func.optional,
onOpen: check.func.optional
}
})
});
onClose: {
bound: 'md-on-close'
},
onOpen: {
bound: 'md-on-open'
}
}
},
apiCheck: (check) => ({
templateOptions: {
options: check.arrayOf(check.object),
multiple: check.bool.optional,
labelProp: check.string.optional,
valueProp: check.string.optional,
onClose: check.func.optional,
onOpen: check.func.optional
}
})
});
}
56 changes: 28 additions & 28 deletions src/types/slider/slider.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import template from './slider.html';

export default (formlyConfigProvider) => {
formlyConfigProvider.setType({
name: 'slider',
template: template,
defaultOptions: {
ngModelAttrs: {
min: {
attribute: 'min'
},
max: {
attribute: 'max'
},
step: {
attribute: 'step'
},
discrete: {
bound: 'md-discrete'
}
}
formlyConfigProvider.setType({
name: 'slider',
template: template,
defaultOptions: {
ngModelAttrs: {
min: {
attribute: 'min'
},
apiCheck: (check) => ({
templateOptions: {
min: check.number.optional,
max: check.number.optional,
step: check.number.optional,
discrete: check.bool.optional
}
})
});
}
max: {
attribute: 'max'
},
step: {
attribute: 'step'
},
discrete: {
bound: 'md-discrete'
}
}
},
apiCheck: (check) => ({
templateOptions: {
min: check.number.optional,
max: check.number.optional,
step: check.number.optional,
discrete: check.bool.optional
}
})
});
}
Loading

0 comments on commit e61a24a

Please sign in to comment.