import coreModule from 'app/angular/core_module';
const template = `
`;
const checkboxTemplate = `
`;
export class SwitchCtrl {
onChange: any;
checked: any;
show: any;
id: any;
label?: string;
/** @ngInject */
constructor($scope: any, private $timeout: any) {
this.show = true;
this.id = $scope.$id;
}
internalOnChange() {
return this.$timeout(() => {
return this.onChange();
});
}
}
export function switchDirective() {
return {
restrict: 'E',
controller: SwitchCtrl,
controllerAs: 'ctrl',
bindToController: true,
scope: {
checked: '=',
label: '@',
labelClass: '@',
tooltip: '@',
switchClass: '@',
onChange: '&',
},
template: template,
};
}
export function checkboxDirective() {
return {
restrict: 'E',
controller: SwitchCtrl,
controllerAs: 'ctrl',
bindToController: true,
scope: {
checked: '=',
label: '@',
labelClass: '@',
tooltip: '@',
switchClass: '@',
onChange: '&',
},
template: checkboxTemplate,
};
}
coreModule.directive('gfFormSwitch', switchDirective);
coreModule.directive('gfFormCheckbox', checkboxDirective);