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


TypeScript jQuery.grep函數代碼示例

本文整理匯總了TypeScript中jQuery.grep函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript grep函數的具體用法?TypeScript grep怎麽用?TypeScript grep使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了grep函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: querySources

  // matchInput can either by a real event source object, an ID, or the function/URL for the source.
  // returns an array of matching source objects.
  querySources(matchInput) {
    let sources = this.otherSources
    let i
    let source

    // given a proper event source object
    for (i = 0; i < sources.length; i++) {
      source = sources[i]

      if (source === matchInput) {
        return [ source ]
      }
    }

    // an ID match
    source = this.getSourceById(EventSource.normalizeId(matchInput))
    if (source) {
      return [ source ]
    }

    // parse as an event source
    matchInput = EventSourceParser.parse(matchInput, this.calendar)
    if (matchInput) {

      return $.grep(sources, function(source) {
        return isSourcesEquivalent(matchInput, source)
      })
    }
  }
開發者ID:caseyjhol,項目名稱:fullcalendar,代碼行數:31,代碼來源:EventManager.ts

示例2:

 $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

示例3: renderBgRanges

  renderBgRanges(eventRanges) {
    // don't render timed background events
    eventRanges = $.grep(eventRanges, function(eventRange: any) {
      return eventRange.eventDef.isAllDay()
    })

    super.renderBgRanges(eventRanges)
  }
開發者ID:caseyjhol,項目名稱:fullcalendar,代碼行數:8,代碼來源:DayGridEventRenderer.ts

示例4: processOptions

  /* Options
  ------------------------------------------------------------------------------------------------------------------*/


  // Parses various options into properties of this object
  processOptions() {
    let slotDuration = this.opt('slotDuration')
    let snapDuration = this.opt('snapDuration')
    let input

    slotDuration = moment.duration(slotDuration)
    snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration

    this.slotDuration = slotDuration
    this.snapDuration = snapDuration
    this.snapsPerSlot = slotDuration / snapDuration // TODO: ensure an integer multiple?

    // might be an array value (for TimelineView).
    // if so, getting the most granular entry (the last one probably).
    input = this.opt('slotLabelFormat')
    if ($.isArray(input)) {
      input = input[input.length - 1]
    }

    this.labelFormat = input ||
      this.opt('smallTimeFormat') // the computed default

    let slots = this.opt('slots')
    if (slots && Array.isArray(slots)) {
      // filter valid slots
      slots = $.grep(slots, function(sl) {
        return sl.hasOwnProperty('start') && sl.hasOwnProperty('end') &&
          typeof(sl.start) === 'string' && typeof(sl.end) === 'string' &&
          sl.start.match(/^[0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?$/) &&
          sl.end.match(/^[0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?$/) &&
          true
      })
      if (slots.length >= 1) { // require at least 1 slot to display properly
        // sort slots by start time
        slots.sort(function(sl1, sl2) {
          let start1 = moment(sl1.start, 'HH:mm:ss')
          let start2 = moment(sl2.start, 'HH:mm:ss')
          if (start1.isBefore(start2)) {
            return -1
          } else if (start2.isBefore(start1)) {
            return 1
          } else {
            return 0
          }
        })

        // make sure each slot ends after it starts, and before the next one starts
        for (let i = 0; i < slots.length; i++) {
          let start1 = moment(slots[i].start, 'HH:mm:ss')
          let end1 = moment(slots[i].end, 'HH:mm:ss')
          if (end1.isBefore(start1)) {
            slots[i].end = slots[i].start
          }
          if (i + 1 < slots.length) {
            let start2 = moment(slots[i + 1].start, 'HH:mm:ss')
            if (start2.isBefore(end1)) {
              slots[i].end = slots[i + 1].start
            }
          }
        }
        this.slots = slots

        // options related to slots
        let showSlotEndTime = this.opt('showSlotEndTime')
        if (showSlotEndTime !== false) { // defaults to true
          this.showSlotEndTime = true
        }
        let showMinorSlotTime = this.opt('showMinorSlotTime')
        if (showMinorSlotTime !== false) { // defaults to true
          this.showMinorSlotTime = true
        }
        let snapOnSlots = this.opt('snapOnSlots')
        if (snapOnSlots && (snapOnSlots === true || // defaults to false
            snapOnSlots.hasOwnProperty('snapPolicy')
          )) {
          this.snapOnSlots = {
            snapPolicy: 'enlarge' // could also be 'closest'
          }
          if (snapOnSlots.snapPolicy === 'closest') {
            this.snapOnSlots.snapPolicy = 'closest'
          }
        }
      }
    }

    input = this.opt('slotLabelInterval')
    this.labelInterval = input ?
      moment.duration(input) :
      this.computeLabelInterval(slotDuration)
  }
開發者ID:kleisauke,項目名稱:fullcalendar,代碼行數:95,代碼來源:TimeGrid.ts

示例5: function

 exec: function (field: string, ctx: JQuery): number {
     return $.grep($(getFieldSelector(field), ctx), function (n) {
         const val = $(n).val() + '';
         return val.length > 0;
     }).length;
 }
開發者ID:c17r,項目名稱:jAutoCalc,代碼行數:6,代碼來源:functions.ts

示例6: getSourceById

 /*
 ID assumed to already be normalized
 */
 getSourceById(id) {
   return $.grep(this.otherSources, function(source: any) {
     return source.id && source.id === id
   })[0]
 }
開發者ID:caseyjhol,項目名稱:fullcalendar,代碼行數:8,代碼來源:EventManager.ts

示例7: removeFalse

export function removeFalse(ar) {
    return $.grep(ar, identity);
}
開發者ID:hraban,項目名稱:lush,代碼行數:3,代碼來源:utils.ts


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