当前位置: 首页>>代码示例>>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;未经允许,请勿转载。