KOSASIH / SilkRoad

Prefer using $timeout instead of setTimeout JS-0562
Anti-pattern
Minor
8 months agoa year old
You should use the $timeout service instead of the default window.setTimeout method
2063	
2064			self.ignoreFocus = true;
2065			self.$control_input[0].focus();
2066			window.setTimeout(function() {2067				self.ignoreFocus = false;
2068				self.onFocus();
2069			}, 0);
You should use the $timeout service instead of the default window.setTimeout method
1549			if (self.settings.splitOn) {
1550	
1551				// Wait for pasted text to be recognized in value
1552				setTimeout(function() {1553					var pastedText = self.$control_input.val();1554					if(!pastedText.match(self.settings.splitOn)){ return }1555	1556					var splitInput = $.trim(pastedText).split(self.settings.splitOn);1557					for (var i = 0, n = splitInput.length; i < n; i++) {1558						self.createItem(splitInput[i]);1559					}1560				}, 0);1561			}
1562		},
1563	
You should use the $timeout service instead of the default window.setTimeout method
1514			} else {
1515				// give control focus
1516				if (!defaultPrevented) {
1517					window.setTimeout(function() {1518						self.focus();
1519					}, 0);
1520				}
You should use the $timeout service instead of the default window.setTimeout method
 889			var self = this;
 890			var args = arguments;
 891			window.clearTimeout(timeout);
 892			timeout = window.setTimeout(function() { 893				fn.apply(self, args);
 894			}, delay);
 895		};
You should use the $timeout service instead of the default window.setTimeout method
1427	
1428			self.ignoreFocus = true;
1429			self.$control_input[0].focus();
1430			window.setTimeout(function() {1431				self.ignoreFocus = false;
1432				self.onFocus();
1433			}, 0);