Skip to content

Commit fcd6983

Browse files
committed
small fixes
1 parent ef2baef commit fcd6983

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

app/js/formus.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
168168
$scope.isValid = true;
169169
$scope.dirty = false;
170170
$scope.validation = function(value) {
171-
if (_.isObject($scope.config.validators)) {
171+
if (angular.isObject($scope.config.validators)) {
172172
$scope.errors = [];
173173
angular.forEach($scope.config.validators, function(args, name) {
174174
var error = FormusValidator.validate(name, value, $scope.config, args);
@@ -191,7 +191,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
191191

192192
var init = function() {
193193
$scope.parentCtrl = $element.parent().controller('formus-field');
194-
if (_.isUndefined($scope.parentCtrl)) {
194+
if (angular.isUndefined($scope.parentCtrl)) {
195195
$scope.parentCtrl = $element.parent().controller('formus-form');
196196
}
197197
$scope.parentScope = $scope.parentCtrl.getScope();
@@ -219,7 +219,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
219219
}
220220
});
221221

222-
$scope.isParent = (!_.isUndefined($scope.config.fields));
222+
$scope.isParent = (!angular.isUndefined($scope.config.fields));
223223
/** Set field type 'fieldset' when it has child fields and don't set other type */
224224
if ($scope.isParent && (_.isUndefined($scope.config.input))) {
225225
$scope.config.input = 'fieldset';
@@ -230,7 +230,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
230230
$element: $element,
231231
$attr: $attr
232232
});
233-
if (_.isFunction($scope.config.linker)) {
233+
if (angular.isFunction($scope.config.linker)) {
234234
$injector.invoke($scope.config.linker, this, {
235235
$scope: $scope,
236236
$element: $element,
@@ -324,7 +324,7 @@ formus.directive('formusForm', function($q, FormusLinker, FormusTemplates, Formu
324324
};
325325
$scope.submit = function() {
326326
$scope.validate().then(function() {
327-
if (typeof($scope.config.submit.handler) === 'function') {
327+
if (angular.isFunction($scope.config.submit.handler)) {
328328
$scope.config.submit.handler();
329329
}
330330
}, angular.noop);
@@ -548,7 +548,7 @@ formus.provider('FormusLinker', function() {
548548
$scope.setElementTemplate = function(templateData) {
549549
$element.html(templateData);
550550
$compile($element.contents())($scope);
551-
if (typeof($scope.afterLoadTemplate) === 'function') {
551+
if (angular.isFunction($scope.afterLoadTemplate)) {
552552
$scope.afterLoadTemplate();
553553
}
554554
};
@@ -591,7 +591,7 @@ formus.provider('FormusLinker', function() {
591591
$scope.config[name] = value;
592592
}
593593
});
594-
if (($scope.config.label) && (typeof($scope.config.showLabel) === 'undefined')) {
594+
if (($scope.config.label) && angular.isUndefined($scope.config.showLabel)) {
595595
$scope.config.showLabel = true;
596596
}
597597
};
@@ -669,7 +669,7 @@ formus.provider('FormusTemplates', function() {
669669
* @param templateUrl
670670
*/
671671
var setTemplateUrl = function(name, templateUrl) {
672-
if (typeof name === 'string') {
672+
if (angular.isString(name)) {
673673
templateMap[name] = templateUrl;
674674
} else {
675675
angular.forEach(name, function(templateUrl, name) {
@@ -804,7 +804,7 @@ formus.provider('FormusValidator', function($logProvider) {
804804
};
805805
};
806806
var set = function(name, callback) {
807-
if (typeof(callback) === 'function') {
807+
if (angular.isFunction(callback)) {
808808
validators[name] = callback;
809809
} else {
810810
$logProvider.warn('Validator must be function. Can\'t set validator with name "' + name + '"');

src/field.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
99
$scope.isValid = true;
1010
$scope.dirty = false;
1111
$scope.validation = function(value) {
12-
if (_.isObject($scope.config.validators)) {
12+
if (angular.isObject($scope.config.validators)) {
1313
$scope.errors = [];
1414
angular.forEach($scope.config.validators, function(args, name) {
1515
var error = FormusValidator.validate(name, value, $scope.config, args);
@@ -32,7 +32,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
3232

3333
var init = function() {
3434
$scope.parentCtrl = $element.parent().controller('formus-field');
35-
if (_.isUndefined($scope.parentCtrl)) {
35+
if (angular.isUndefined($scope.parentCtrl)) {
3636
$scope.parentCtrl = $element.parent().controller('formus-form');
3737
}
3838
$scope.parentScope = $scope.parentCtrl.getScope();
@@ -60,7 +60,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
6060
}
6161
});
6262

63-
$scope.isParent = (!_.isUndefined($scope.config.fields));
63+
$scope.isParent = (!angular.isUndefined($scope.config.fields));
6464
/** Set field type 'fieldset' when it has child fields and don't set other type */
6565
if ($scope.isParent && (_.isUndefined($scope.config.input))) {
6666
$scope.config.input = 'fieldset';
@@ -71,7 +71,7 @@ formus.directive('formusField', function($injector, $http, $compile, $log, $temp
7171
$element: $element,
7272
$attr: $attr
7373
});
74-
if (_.isFunction($scope.config.linker)) {
74+
if (angular.isFunction($scope.config.linker)) {
7575
$injector.invoke($scope.config.linker, this, {
7676
$scope: $scope,
7777
$element: $element,

src/form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ formus.directive('formusForm', function($q, FormusLinker, FormusTemplates, Formu
6767
};
6868
$scope.submit = function() {
6969
$scope.validate().then(function() {
70-
if (typeof($scope.config.submit.handler) === 'function') {
70+
if (angular.isFunction($scope.config.submit.handler)) {
7171
$scope.config.submit.handler();
7272
}
7373
}, angular.noop);

src/linker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ formus.provider('FormusLinker', function() {
77
$scope.setElementTemplate = function(templateData) {
88
$element.html(templateData);
99
$compile($element.contents())($scope);
10-
if (typeof($scope.afterLoadTemplate) === 'function') {
10+
if (angular.isFunction($scope.afterLoadTemplate)) {
1111
$scope.afterLoadTemplate();
1212
}
1313
};
@@ -50,7 +50,7 @@ formus.provider('FormusLinker', function() {
5050
$scope.config[name] = value;
5151
}
5252
});
53-
if (($scope.config.label) && (typeof($scope.config.showLabel) === 'undefined')) {
53+
if (($scope.config.label) && angular.isUndefined($scope.config.showLabel)) {
5454
$scope.config.showLabel = true;
5555
}
5656
};

src/templates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ formus.provider('FormusTemplates', function() {
2424
* @param templateUrl
2525
*/
2626
var setTemplateUrl = function(name, templateUrl) {
27-
if (typeof name === 'string') {
27+
if (angular.isString(name)) {
2828
templateMap[name] = templateUrl;
2929
} else {
3030
angular.forEach(name, function(templateUrl, name) {

src/validator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ formus.provider('FormusValidator', function($logProvider) {
6464
};
6565
};
6666
var set = function(name, callback) {
67-
if (typeof(callback) === 'function') {
67+
if (angular.isFunction(callback)) {
6868
validators[name] = callback;
6969
} else {
7070
$logProvider.warn('Validator must be function. Can\'t set validator with name "' + name + '"');

0 commit comments

Comments
 (0)