Уборка Unreachable statement. Замена === на == и !== на != в яваскриптах из-за ошибок с нестрогой типизацией при переходе на 7.4.
This commit is contained in:
+44
-44
@@ -8,9 +8,9 @@
|
||||
|
||||
(function (factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
if (typeof define == 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object' && typeof require === 'function') {
|
||||
} else if (typeof exports == 'object' && typeof require == 'function') {
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery);
|
||||
@@ -75,11 +75,11 @@
|
||||
triggerSelectOnValidInput: true,
|
||||
preventBadQueries: true,
|
||||
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
|
||||
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
|
||||
return suggestion.value.toLowerCase().indexOf(queryLowerCase) != -1;
|
||||
},
|
||||
paramName: 'query',
|
||||
transformResult: function (response) {
|
||||
return typeof response === 'string' ? $.parseJSON(response) : response;
|
||||
return typeof response == 'string' ? $.parseJSON(response) : response;
|
||||
},
|
||||
showNoSuggestionNotice: false,
|
||||
noSuggestionNotice: 'No results',
|
||||
@@ -140,7 +140,7 @@
|
||||
that.element.setAttribute('autocomplete', 'off');
|
||||
|
||||
that.killerFn = function (e) {
|
||||
if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
|
||||
if ($(e.target).closest('.' + that.options.containerClass).length == 0) {
|
||||
that.killSuggestions();
|
||||
that.disableKillerFn();
|
||||
}
|
||||
@@ -157,7 +157,7 @@
|
||||
container.appendTo(options.appendTo);
|
||||
|
||||
// Only set width if it was provided:
|
||||
if (options.width !== 'auto') {
|
||||
if (options.width != 'auto') {
|
||||
container.width(options.width);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
containerParent = $container.parent().get(0);
|
||||
// Fix position automatically when appended to body.
|
||||
// In other cases force parameter must be given.
|
||||
if (containerParent !== document.body && !that.options.forceFixPosition) {
|
||||
if (containerParent != document.body && !that.options.forceFixPosition) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,16 +271,16 @@
|
||||
offset = that.el.offset(),
|
||||
styles = { 'top': offset.top, 'left': offset.left };
|
||||
|
||||
if (orientation === 'auto') {
|
||||
if (orientation == 'auto') {
|
||||
var viewPortHeight = $(window).height(),
|
||||
scrollTop = $(window).scrollTop(),
|
||||
topOverflow = -scrollTop + offset.top - containerHeight,
|
||||
bottomOverflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight);
|
||||
|
||||
orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow) ? 'top' : 'bottom';
|
||||
orientation = (Math.max(topOverflow, bottomOverflow) == topOverflow) ? 'top' : 'bottom';
|
||||
}
|
||||
|
||||
if (orientation === 'top') {
|
||||
if (orientation == 'top') {
|
||||
styles.top += -containerHeight;
|
||||
} else {
|
||||
styles.top += height;
|
||||
@@ -288,7 +288,7 @@
|
||||
|
||||
// If container is not positioned to body,
|
||||
// correct its position using offset parent offset
|
||||
if(containerParent !== document.body) {
|
||||
if(containerParent != document.body) {
|
||||
var opacity = $container.css('opacity'),
|
||||
parentOffsetDiff;
|
||||
|
||||
@@ -306,7 +306,7 @@
|
||||
}
|
||||
|
||||
// -2px to account for suggestions border.
|
||||
if (that.options.width === 'auto') {
|
||||
if (that.options.width == 'auto') {
|
||||
styles.width = (that.el.outerWidth() - 2) + 'px';
|
||||
}
|
||||
|
||||
@@ -342,13 +342,13 @@
|
||||
selectionStart = that.element.selectionStart,
|
||||
range;
|
||||
|
||||
if (typeof selectionStart === 'number') {
|
||||
return selectionStart === valLength;
|
||||
if (typeof selectionStart == 'number') {
|
||||
return selectionStart == valLength;
|
||||
}
|
||||
if (document.selection) {
|
||||
range = document.selection.createRange();
|
||||
range.moveStart('character', -valLength);
|
||||
return valLength === range.text.length;
|
||||
return valLength == range.text.length;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -357,7 +357,7 @@
|
||||
var that = this;
|
||||
|
||||
// If suggestions are hidden and user presses arrow down, display suggestions:
|
||||
if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
|
||||
if (!that.disabled && !that.visible && e.which == keys.DOWN && that.currentValue) {
|
||||
that.suggest();
|
||||
return;
|
||||
}
|
||||
@@ -382,17 +382,17 @@
|
||||
that.selectHint();
|
||||
return;
|
||||
}
|
||||
if (that.selectedIndex === -1) {
|
||||
if (that.selectedIndex == -1) {
|
||||
that.hide();
|
||||
return;
|
||||
}
|
||||
that.select(that.selectedIndex);
|
||||
if (that.options.tabDisabled === false) {
|
||||
if (that.options.tabDisabled == false) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case keys.RETURN:
|
||||
if (that.selectedIndex === -1) {
|
||||
if (that.selectedIndex == -1) {
|
||||
that.hide();
|
||||
return;
|
||||
}
|
||||
@@ -428,7 +428,7 @@
|
||||
|
||||
clearInterval(that.onChangeInterval);
|
||||
|
||||
if (that.currentValue !== that.el.val()) {
|
||||
if (that.currentValue != that.el.val()) {
|
||||
that.findBestHint();
|
||||
if (that.options.deferRequestBy > 0) {
|
||||
// Defer lookup in case when value changes very quickly:
|
||||
@@ -448,7 +448,7 @@
|
||||
query = that.getQuery(value),
|
||||
index;
|
||||
|
||||
if (that.selection && that.currentValue !== query) {
|
||||
if (that.selection && that.currentValue != query) {
|
||||
that.selection = null;
|
||||
(options.onInvalidateSelection || $.noop).call(that.element);
|
||||
}
|
||||
@@ -460,7 +460,7 @@
|
||||
// Check existing suggestion for the match before proceeding:
|
||||
if (options.triggerSelectOnValidInput) {
|
||||
index = that.findSuggestionIndex(query);
|
||||
if (index !== -1) {
|
||||
if (index != -1) {
|
||||
that.select(index);
|
||||
return;
|
||||
}
|
||||
@@ -479,7 +479,7 @@
|
||||
queryLowerCase = query.toLowerCase();
|
||||
|
||||
$.each(that.suggestions, function (i, suggestion) {
|
||||
if (suggestion.value.toLowerCase() === queryLowerCase) {
|
||||
if (suggestion.value.toLowerCase() == queryLowerCase) {
|
||||
index = i;
|
||||
return false;
|
||||
}
|
||||
@@ -532,7 +532,7 @@
|
||||
options.params[options.paramName] = q;
|
||||
params = options.ignoreParams ? null : options.params;
|
||||
|
||||
if (options.onSearchStart.call(that.element, options.params) === false) {
|
||||
if (options.onSearchStart.call(that.element, options.params) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@
|
||||
i = badQueries.length;
|
||||
|
||||
while (i--) {
|
||||
if (q.indexOf(badQueries[i]) === 0) {
|
||||
if (q.indexOf(badQueries[i]) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -614,7 +614,7 @@
|
||||
},
|
||||
|
||||
suggest: function () {
|
||||
if (this.suggestions.length === 0) {
|
||||
if (this.suggestions.length == 0) {
|
||||
if (this.options.showNoSuggestionNotice) {
|
||||
this.noSuggestions();
|
||||
} else {
|
||||
@@ -638,7 +638,7 @@
|
||||
formatGroup = function (suggestion, index) {
|
||||
var currentCategory = suggestion.data[groupBy];
|
||||
|
||||
if (category === currentCategory){
|
||||
if (category == currentCategory){
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@
|
||||
|
||||
if (options.triggerSelectOnValidInput) {
|
||||
index = that.findSuggestionIndex(value);
|
||||
if (index !== -1) {
|
||||
if (index != -1) {
|
||||
that.select(index);
|
||||
return;
|
||||
}
|
||||
@@ -717,7 +717,7 @@
|
||||
// because if instance was created before input had width, it will be zero.
|
||||
// Also it adjusts if input width has changed.
|
||||
// -2px to account for suggestions border.
|
||||
if (options.width === 'auto') {
|
||||
if (options.width == 'auto') {
|
||||
width = that.el.outerWidth() - 2;
|
||||
container.width(width > 0 ? width : 300);
|
||||
}
|
||||
@@ -733,7 +733,7 @@
|
||||
}
|
||||
|
||||
$.each(that.suggestions, function (i, suggestion) {
|
||||
var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
|
||||
var foundMatch = suggestion.value.toLowerCase().indexOf(value) == 0;
|
||||
if (foundMatch) {
|
||||
bestMatch = suggestion;
|
||||
}
|
||||
@@ -749,7 +749,7 @@
|
||||
if (suggestion) {
|
||||
hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
|
||||
}
|
||||
if (that.hintValue !== hintValue) {
|
||||
if (that.hintValue != hintValue) {
|
||||
that.hintValue = hintValue;
|
||||
that.hint = suggestion;
|
||||
(this.options.onHint || $.noop)(hintValue);
|
||||
@@ -758,7 +758,7 @@
|
||||
|
||||
verifySuggestionsFormat: function (suggestions) {
|
||||
// If suggestions is string array, convert them to supported format:
|
||||
if (suggestions.length && typeof suggestions[0] === 'string') {
|
||||
if (suggestions.length && typeof suggestions[0] == 'string') {
|
||||
return $.map(suggestions, function (value) {
|
||||
return { value: value, data: null };
|
||||
});
|
||||
@@ -770,7 +770,7 @@
|
||||
validateOrientation: function(orientation, fallback) {
|
||||
orientation = $.trim(orientation || '').toLowerCase();
|
||||
|
||||
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
|
||||
if($.inArray(orientation, ['auto', 'bottom', 'top']) == -1){
|
||||
orientation = fallback;
|
||||
}
|
||||
|
||||
@@ -786,13 +786,13 @@
|
||||
// Cache results if cache is not disabled:
|
||||
if (!options.noCache) {
|
||||
that.cachedResponse[cacheKey] = result;
|
||||
if (options.preventBadQueries && result.suggestions.length === 0) {
|
||||
if (options.preventBadQueries && result.suggestions.length == 0) {
|
||||
that.badQueries.push(originalQuery);
|
||||
}
|
||||
}
|
||||
|
||||
// Return if originalQuery is not matching current query:
|
||||
if (originalQuery !== that.getQuery(that.currentValue)) {
|
||||
if (originalQuery != that.getQuery(that.currentValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@
|
||||
|
||||
that.selectedIndex = index;
|
||||
|
||||
if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
|
||||
if (that.selectedIndex != -1 && children.length > that.selectedIndex) {
|
||||
activeItem = children.get(that.selectedIndex);
|
||||
$(activeItem).addClass(selected);
|
||||
return activeItem;
|
||||
@@ -836,11 +836,11 @@
|
||||
moveUp: function () {
|
||||
var that = this;
|
||||
|
||||
if (that.selectedIndex === -1) {
|
||||
if (that.selectedIndex == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (that.selectedIndex === 0) {
|
||||
if (that.selectedIndex == 0) {
|
||||
$(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
|
||||
that.selectedIndex = -1;
|
||||
that.el.val(that.currentValue);
|
||||
@@ -854,7 +854,7 @@
|
||||
moveDown: function () {
|
||||
var that = this;
|
||||
|
||||
if (that.selectedIndex === (that.suggestions.length - 1)) {
|
||||
if (that.selectedIndex == (that.suggestions.length - 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -897,7 +897,7 @@
|
||||
|
||||
that.currentValue = that.getValue(suggestion.value);
|
||||
|
||||
if (that.currentValue !== that.el.val() && !that.options.preserveInput) {
|
||||
if (that.currentValue != that.el.val() && !that.options.preserveInput) {
|
||||
that.el.val(that.currentValue);
|
||||
}
|
||||
|
||||
@@ -923,7 +923,7 @@
|
||||
currentValue = that.currentValue;
|
||||
parts = currentValue.split(delimiter);
|
||||
|
||||
if (parts.length === 1) {
|
||||
if (parts.length == 1) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -944,7 +944,7 @@
|
||||
var dataKey = 'autocomplete';
|
||||
// If function invoked without argument return
|
||||
// instance of the first matched element:
|
||||
if (arguments.length === 0) {
|
||||
if (arguments.length == 0) {
|
||||
return this.first().data(dataKey);
|
||||
}
|
||||
|
||||
@@ -952,8 +952,8 @@
|
||||
var inputElement = $(this),
|
||||
instance = inputElement.data(dataKey);
|
||||
|
||||
if (typeof options === 'string') {
|
||||
if (instance && typeof instance[options] === 'function') {
|
||||
if (typeof options == 'string') {
|
||||
if (instance && typeof instance[options] == 'function') {
|
||||
instance[options](args);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user