refactor code

This commit is contained in:
MaysWind 2016-06-26 14:21:20 +08:00
parent 8966750ac8
commit 1d5b8a6ee1
3 changed files with 13 additions and 13 deletions

View file

@ -146,7 +146,7 @@
return;
}
if ((scope.option.type == 'integer' || scope.option.type == 'float') && (!angular.isUndefined(scope.option.min) || !angular.isUndefined(scope.option.max))) {
if ((scope.option.type == 'integer' || scope.option.type == 'float') && (angular.isDefined(scope.option.min) || angular.isDefined(scope.option.max))) {
var number = optionValue;
if (scope.option.type == 'integer') {
@ -155,18 +155,18 @@
number = parseFloat(optionValue);
}
if (!angular.isUndefined(scope.option.min) && number < scope.option.min) {
if (angular.isDefined(scope.option.min) && number < scope.option.min) {
scope.optionStatus.setError('Input number is below min value!', { value: scope.option.min });
return;
}
if (!angular.isUndefined(scope.option.max) && number > scope.option.max) {
if (angular.isDefined(scope.option.max) && number > scope.option.max) {
scope.optionStatus.setError('Input number is above max value!', { value: scope.option.max });
return;
}
}
if (!angular.isUndefined(scope.option.pattern) && !(new RegExp(scope.option.pattern).test(optionValue))) {
if (angular.isDefined(scope.option.pattern) && !(new RegExp(scope.option.pattern).test(optionValue))) {
scope.optionStatus.setError('Input value is invalid!');
return;
}

View file

@ -128,7 +128,7 @@
if (arguments.length > 2) {
for (var i = 2; i < arguments.length; i++) {
if (arguments[i] != null && !angular.isUndefined(arguments[i])) {
if (arguments[i] != null && angular.isDefined(arguments[i])) {
finalParams.push(arguments[i]);
}
}
@ -285,21 +285,21 @@
},
tellActive: function (context) {
return invoke(buildRequestContext('tellActive', context,
angular.isUndefined(context.requestParams) ? null : context.requestParams
angular.isDefined(context.requestParams) ? context.requestParams: null
));
},
tellWaiting: function (context) {
return invoke(buildRequestContext('tellWaiting', context,
angular.isUndefined(context.offset) ? 0 : context.offset,
angular.isUndefined(context.num) ? 1000 : context.num,
angular.isUndefined(context.requestParams) ? null : context.requestParams
angular.isDefined(context.offset) ? context.offset : 0,
angular.isDefined(context.num) ? context.num : 1000,
angular.isDefined(context.requestParams) ? context.requestParams : null
));
},
tellStopped: function (context) {
return invoke(buildRequestContext('tellStopped', context,
angular.isUndefined(context.offset) ? 0 : context.offset,
angular.isUndefined(context.num) ? 1000 : context.num,
angular.isUndefined(context.requestParams) ? null : context.requestParams
angular.isDefined(context.offset) ? context.offset : 0,
angular.isDefined(context.num) ? context.num : 1000,
angular.isDefined(context.requestParams) ? context.requestParams: null
));
},
changePosition: function (context) {

View file

@ -97,7 +97,7 @@
};
var isStorageExist = function (key) {
return !angular.isUndefined(storagesInMemory[key]);
return angular.isDefined(storagesInMemory[key]);
};
var pushToStorage = function (key, stat) {