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; 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; var number = optionValue;
if (scope.option.type == 'integer') { if (scope.option.type == 'integer') {
@ -155,18 +155,18 @@
number = parseFloat(optionValue); 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 }); scope.optionStatus.setError('Input number is below min value!', { value: scope.option.min });
return; 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 }); scope.optionStatus.setError('Input number is above max value!', { value: scope.option.max });
return; 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!'); scope.optionStatus.setError('Input value is invalid!');
return; return;
} }

View file

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

View file

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