本文整理汇总了TypeScript中jQuery.inArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inArray函数的具体用法?TypeScript inArray怎么用?TypeScript inArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inArray函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: remove
remove(positions: JQueryTab.TabItemPosition[]) {
if (!positions.length) {
return;
}
const {getter, saveLoad, switcher, context} = this;
const removeIndecies = [];
for (let i = 0, len = positions.length; i < len; i++) {
const removeIndex = getter.positionToIndex(positions[i]);
if (removeIndex >= 0 && removeIndex < context.itemCount && $.inArray(removeIndex, removeIndecies) === -1) {
removeIndecies.push(removeIndex);
}
}
if (!removeIndecies.length) {
return;
}
removeIndecies.sort(function (prev, next) {
return next - prev;
});
if (context.itemCount > 1 && $.inArray(context.currentIndex, removeIndecies) >= 0) {
switcher.switchNext({exclude: removeIndecies}) ||
switcher.switchPrevious({exclude: removeIndecies}) ||
switcher.switchNext({includeDisabled: true, exclude: removeIndecies}) ||
switcher.switchPrevious({includeDisabled: true, exclude: removeIndecies}) ||
switcher.switchNext({includeHidden: true, exclude: removeIndecies}) ||
switcher.switchPrevious({includeHidden: true, exclude: removeIndecies}) ||
switcher.switchNext({includeDisabled: true, includeHidden: true, exclude: removeIndecies}) ||
switcher.switchPrevious({includeDisabled: true, includeHidden: true, exclude: removeIndecies});
}
let currentIndexChanged = false;
for (let i = 0, len = removeIndecies.length; i < len; i++) {
const removeIndex = removeIndecies[i];
const $labelItems = getter.getHeaderFooterLabels(removeIndex);
const $panelItem = getter.getPanel(removeIndex);
$labelItems.remove();
$panelItem.remove();
if (removeIndex < context.currentIndex) {
context.currentIndex--;
currentIndexChanged = true;
}
context.itemCount--;
}
if (context.itemCount === 0) {
context.currentIndex = -1;
context.currentName = undefined;
}
else if (currentIndexChanged && !context.currentName) {
saveLoad.savePosition(context.currentIndex);
}
return removeIndecies.length;
}
示例2: _switchNeighbor
private _switchNeighbor(
fromIndex: number,
direction: SwitchDirection,
switchOptions?: JQueryTab.SwitchOptions
): JQueryTab.SwitchResult {
const {getter} = this;
const opts = switchOptions || {};
const {includeDisabled, includeHidden, loop, exclude} = opts;
const excludeIndecies = exclude && exclude.length ? $.map(exclude, function (position) {
return getter.positionToIndex(position);
}) : [];
const {$panelContainer} = this.containers;
const $panelItems = $panelContainer.children();
const {itemCount} = this.context;
const {disabledPanelItemClass, hiddenPanelItemClass} = this.options;
let maxIterationCount = -1;
if (loop) {
if (fromIndex >= 0 && fromIndex < itemCount) {
maxIterationCount = itemCount - 1;
} else {
maxIterationCount = itemCount;
}
} else if (direction === SwitchDirection.Backward) {
maxIterationCount = fromIndex;
} else if (direction === SwitchDirection.Forward) {
maxIterationCount = itemCount - fromIndex - 1;
}
const iterationStep = direction === SwitchDirection.Backward ? -1 : 1;
for (let i = 1; i <= maxIterationCount; i++) {
const panelIndex = (fromIndex + i * iterationStep + itemCount) % itemCount;
if ($.inArray(panelIndex, excludeIndecies) >= 0) {
continue;
}
const $panel = $panelItems.eq(panelIndex);
const panelIsDisabled = $panel.hasClass(disabledPanelItemClass);
const panelIsHidden = $panel.hasClass(hiddenPanelItemClass);
if (
(!panelIsDisabled && !panelIsHidden) ||
(includeDisabled && !panelIsHidden) ||
(!panelIsDisabled && includeHidden) ||
(includeDisabled && includeHidden)
) {
return this.switchTo(panelIndex);
}
}
}
示例3: function
Constraints.prototype.isFootprintAllowed = function(footprint, peerEventFootprints, constraintVal, overlapVal, subjectEventInstance) {
if (typeof constraintVal === 'object') {
const constrainToResourceIds = Resource.extractIds(constraintVal, this)
if (constrainToResourceIds.length && (
!(footprint instanceof ResourceComponentFootprint) ||
$.inArray(footprint.resourceId, constrainToResourceIds) === -1
)) {
return false
}
}
return origMethods.isFootprintAllowed.apply(this, arguments)
}
示例4: isValidKey
export function isValidKey(key) {
if ($.inArray(key, PRESET_LICENSE_KEYS) !== -1) {
return true
}
const parts = (key || '').match(/^(\d+)\-fcs\-(\d+)$/)
if (parts && (parts[1].length === 10)) {
const purchaseDate = moment.utc(parseInt(parts[2], 10) * 1000)
const releaseDate = moment.utc((exportHooks as any).mockSchedulerReleaseDate || RELEASE_DATE)
if (releaseDate.isValid()) { // token won't be replaced in dev mode
const minPurchaseDate = releaseDate.clone().subtract(UPGRADE_WINDOW)
if (purchaseDate.isAfter(minPurchaseDate)) {
return true
}
}
}
return false
}
示例5: getUnitViewSpec
// Given a duration singular unit, like "week" or "day", finds a matching view spec.
// Preference is given to views that have corresponding buttons.
getUnitViewSpec(unit) {
let viewTypes
let i
let spec
if ($.inArray(unit, unitsDesc) !== -1) {
// put views that have buttons first. there will be duplicates, but oh well
viewTypes = this._calendar.header.getViewsWithButtons() // TODO: include footer as well?
$.each(viewHash, function(viewType) { // all views
viewTypes.push(viewType)
})
for (i = 0; i < viewTypes.length; i++) {
spec = this.getViewSpec(viewTypes[i])
if (spec) {
if (spec.singleUnit === unit) {
return spec
}
}
}
}
}
示例6: numCleanse
export function numCleanse(value: string | number | string[], opts: IOptions, numberFormat: INumberFormat): string {
const fieldValue = value + '';
const sepOpts = opts.decimalOpts.concat(opts.thousandOpts);
const numOpts = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'];
let numValue = '';
let ch = '';
let dec = '';
let decLoc = -1;
let thou = '';
let sym = '';
let symLoc = -1;
let decPlaces = 0;
for (let z = fieldValue.length - 1; z >= 0; z--) {
ch = fieldValue.charAt(z);
if ($.inArray(ch, numOpts) != -1) {
numValue = ch + numValue;
} else {
if (dec == '' && $.inArray(ch, opts.decimalOpts) != -1) {
decLoc = z;
dec = ch;
numValue = '.' + numValue;
} else if (thou == '' && $.inArray(ch, opts.thousandOpts) != -1) {
thou = ch;
} else if (sym == '' && $.inArray(ch, sepOpts) == -1 && (z == 0 || z == fieldValue.length - 1)) {
sym = ch;
symLoc = z;
}
}
}
if (dec != '') {
decPlaces = fieldValue.length - decLoc - 1;
if (symLoc > decLoc) {
decPlaces--;
}
}
if (opts.decimalPlaces != -1) {
decPlaces = opts.decimalPlaces;
}
if (arguments.length === 3) {
if (numberFormat.dec == '' && dec != '') {
numberFormat.dec = dec;
}
if ((numberFormat.decPlaces == -1 && decPlaces != -1) ||
(numberFormat.decPlaces != -1 && decPlaces != -1 && decPlaces < numberFormat.decPlaces)) {
numberFormat.decPlaces = decPlaces;
}
if (numberFormat.thou == '' && thou != '') {
numberFormat.thou = thou;
}
if (numberFormat.sym == '' && sym != '') {
numberFormat.sym = sym;
numberFormat.symLoc = symLoc;
}
}
if (opts.emptyAsZero && numValue == '') {
numValue = '0';
}
return numValue;
};
示例7: function
EventDef.prototype.hasResourceId = function(resourceId) {
return $.inArray(resourceId, this.resourceIds) !== -1
}
示例8:
return this.clientEvents((event) => {
return $.inArray(resource.id, this.getEventResourceIds(event)) !== -1
})