當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript jQuery.map函數代碼示例

本文整理匯總了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;
     })
開發者ID:hraban,項目名稱:lush,代碼行數:7,代碼來源:path.ts

示例2:

 (data:any) => {
     $results
         .empty()
         .append ($.map(data[1], (v) => {
             return $('<li>').text(v);
         }));
 }
開發者ID:bsorrentino,項目名稱:rxjs-samples,代碼行數:7,代碼來源:autocomplete.ts

示例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;
}
開發者ID:hraban,項目名稱:lush,代碼行數:9,代碼來源:utils.ts

示例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);
			}
		}
	}
開發者ID:mjpclab,項目名稱:jquery-tab,代碼行數:51,代碼來源:switcher.ts

示例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');
        }
      });
    });
  }
開發者ID:mblag,項目名稱:TYPO3.CMS,代碼行數:39,代碼來源:OnlineMedia.ts

示例6:

 socket.on("users", (users: string []) => {
     $("#users")
         .empty()
         .append($.map(users, user => { return $("<li>").text(user); }));
 });
開發者ID:jaxx,項目名稱:battleship,代碼行數:5,代碼來源:index.ts

示例7: function

 $(ctrl).on("path", function (_, pathjson) {
     var dirs = JSON.parse(pathjson);
     $('ol', $form)
         .empty()
         .append($.map(dirs, createPathInput));
 });
開發者ID:hraban,項目名稱:lush,代碼行數:6,代碼來源:path.ts

示例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);
}
開發者ID:drdim,項目名稱:farmbot-web-frontend,代碼行數:5,代碼來源:util.ts


注:本文中的jQuery.map函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。