本文整理汇总了TypeScript中jQuery.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了map函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
$form.submit(function () {
var paths = $.map($('input', $form), U.attrgetter('value'));
// filter out empty paths
paths = $.grep(paths, U.identity);
ctrl.send('setpath', JSON.stringify(paths));
return false;
})
示例2:
(data:any) => {
$results
.empty()
.append ($.map(data[1], (v) => {
return $('<li>').text(v);
}));
}
示例3: groupby
export function groupby(objs, keyfun) {
var groups = {};
$.map(objs, function (obj) {
var key = keyfun(obj);
// [] if no such group yet
groups[key] = (groups[key] || []).concat(obj);
});
return groups;
}
示例4: _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);
}
}
}
示例5: triggerModal
/**
* @param {JQuery} $currentTarget
*/
private triggerModal($currentTarget: JQuery): void {
const btnSubmit = $currentTarget.data('data-btn-submit') || 'Add';
const placeholder = $currentTarget.data('placeholder') || 'Paste media url here...';
const allowedExtMarkup = $.map($currentTarget.data('online-media-allowed').split(','), (ext: string): string => {
return '<span class="label label-success">' + ext.toUpperCase() + '</span>';
});
const allowedHelpText = $currentTarget.data('online-media-allowed-help-text') || 'Allow to embed from sources:';
const $modal = Modal.show(
$currentTarget.attr('title'),
'<div class="form-control-wrap">' +
'<input type="text" class="form-control online-media-url" placeholder="' + placeholder + '" />' +
'</div><div class="help-block">' + allowedHelpText + '<br>' + allowedExtMarkup.join(' ') + '</div>',
Severity.notice,
[{
text: btnSubmit,
btnClass: 'btn btn-primary',
name: 'ok',
trigger: (): void => {
const url = $modal.find('input.online-media-url').val();
if (url) {
$modal.modal('hide');
this.addOnlineMedia($currentTarget, url);
}
}
}]
);
$modal.on('shown.bs.modal', (e: JQueryEventObject): void => {
// focus the input field
$(e.currentTarget).find('input.online-media-url').first().focus().on('keydown', (kdEvt: JQueryEventObject): void => {
if (kdEvt.keyCode === KeyTypesEnum.ENTER) {
$modal.find('button[name="ok"]').trigger('click');
}
});
});
}
示例6:
socket.on("users", (users: string []) => {
$("#users")
.empty()
.append($.map(users, user => { return $("<li>").text(user); }));
});
示例7: function
$(ctrl).on("path", function (_, pathjson) {
var dirs = JSON.parse(pathjson);
$('ol', $form)
.empty()
.append($.map(dirs, createPathInput));
});
示例8: convertFormToObject
export function convertFormToObject(formEl: Element) {
let inputs = $(formEl.querySelectorAll("input"));
let values = $.map(inputs, function(d) { return [[d.name, d.value]]; });
return _.object(values);
}