How to use the jquery.inArray function in jquery

To help you get started, we’ve selected a few jquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fengyuanchen / datepicker / src / js / handlers.js View on Github external
case 'month picked':
        if (format.hasDay) {
          this.showView(VIEWS.DAYS);
        } else {
          $target.siblings(`.${options.pickedClass}`)
            .removeClass(options.pickedClass)
            .data('view', 'month');
          this.hideView();
        }

        this.pick('month');
        break;

      case 'month':
        viewMonth = $.inArray($target.text(), options.monthsShort);
        date.setFullYear(viewYear);

        // Set date before month to avoid month changing (#195)
        date.setDate(getMinDay(viewYear, viewMonth, viewDay));
        date.setMonth(viewMonth);
        viewDate.setFullYear(viewYear);
        viewDate.setDate(getMinDay(viewYear, viewMonth, viewDay));
        viewDate.setMonth(viewMonth);

        if (format.hasDay) {
          this.showView(VIEWS.DAYS);
        } else {
          $target.addClass(options.pickedClass)
            .data('view', 'month picked')
            .siblings(`.${options.pickedClass}`)
            .removeClass(options.pickedClass)
github EuroPython / epcon / data / static / cms / js / modules / cms.plugins.js View on Github external
_toggleCollapsable: function toggleCollapsable(el) {
        var that = this;
        var id = that._getId(el.parent());
        var draggable = this.ui.draggable;
        var items;

        var settings = CMS.settings;

        settings.states = settings.states || [];

        // collapsable function and save states
        if (el.hasClass('cms-dragitem-expanded')) {
            settings.states.splice($.inArray(id, settings.states), 1);
            el.removeClass('cms-dragitem-expanded').parent()
                .find('> .cms-collapsable-container').addClass('cms-hidden');

            if (doc.data('expandmode')) {
                items = draggable.find('.cms-draggable').find('.cms-dragitem-collapsable');
                if (!items.length) {
                    return false;
                }
                items.each(function () {
                    var item = $(this);

                    if (item.hasClass('cms-dragitem-expanded')) {
                        that._toggleCollapsable(item);
                    }
                });
            }
github OpenGeoscience / geojs / tests / cases / annotation.js View on Github external
it('featuresForAnnotations', function () {
      var features = geo.featuresForAnnotations(['polygon']);
      expect($.inArray('polygon', features) >= 0).toBe(true);
      expect($.inArray('line.basic', features) >= 0).toBe(true);
      expect($.inArray('point', features) >= 0).toBe(false);
      features = geo.featuresForAnnotations({polygon: true});
      expect($.inArray('polygon', features) >= 0).toBe(true);
      expect($.inArray('line.basic', features) >= 0).toBe(true);
      expect($.inArray('point', features) >= 0).toBe(false);
      features = geo.featuresForAnnotations({polygon: [geo.annotation.state.done]});
      expect($.inArray('polygon', features) >= 0).toBe(true);
      expect($.inArray('line.basic', features) >= 0).toBe(false);
      expect($.inArray('point', features) >= 0).toBe(false);
      features = geo.featuresForAnnotations({polygon: [geo.annotation.state.done, geo.annotation.state.create]});
      expect($.inArray('polygon', features) >= 0).toBe(true);
      expect($.inArray('line.basic', features) >= 0).toBe(true);
      expect($.inArray('point', features) >= 0).toBe(false);
      features = geo.featuresForAnnotations(['polygon', 'point']);
      expect($.inArray('polygon', features) >= 0).toBe(true);
      expect($.inArray('line.basic', features) >= 0).toBe(true);
      expect($.inArray('point', features) >= 0).toBe(true);
github digitalgreenorg / dg / dg / media / social_website / build / app / view-controllers / DeoAnalyticsViewController.js View on Github external
setMonth: function()
        {
            var references = this._references
            var userdate = jQuery('#dateshow').html();
            var first = userdate.split(" ");

            if ((jQuery.inArray(first[0], references.days) >= 0)) //coming to MONTHLY view from DAILY view
            {
                var mydate = this.getScreenDate(1);
                this.setMonthDate(mydate);
            }
            else if (first[0] == parseInt(first[0])) //coming to MONTHLY view from WEEKLY view
            {
                var dates = userdate.split("-");
                var date2 = this.getScreenWeekDate(1, dates[1]);        
                this.setMonthDate(date2);
            }
        },
github Esri / storymap-crowdsource / src / app / stores / CrowdsourceAppStore.babel.js View on Github external
break;
    case ActionTypes.map.STORE_MAP_OBJECTS:
      _map = payload.map;
      _layer = payload.layer;
      CrowdsourceAppStore.emitChange();
      break;
    case ActionTypes.forms.FORM_CREATED:
      _formErrors[payload.formId] = [];
      break;
    case ActionTypes.forms.FORM_COMPLETED:
      delete _formErrors[payload.formId];
      break;
    case ActionTypes.forms.VALIDATION_STARTED:
    case ActionTypes.forms.VALIDATION_FINISHED:
      const errorArray = _formErrors[payload.formId];
      const nodeIndex = $.inArray(payload.node,errorArray);

      if (errorArray) {
        if (action === ActionTypes.forms.VALIDATION_FINISHED && nodeIndex > -1 && payload.valid) {
          errorArray.splice(nodeIndex,1);
        } else if (nodeIndex === -1 && !payload.valid) {
          errorArray.push(payload.node);
        }
        CrowdsourceAppStore.emitChange(Events.forms.VALIDATION_EVENT);
      }
      break;
    case ActionTypes.contribute.START:
      _contributeGraphic = {
        attributes: {
          hidden: 0,
          vetted: 0
        }
github thomaspark / fontcdn / app / Fonts / Fonts.js View on Github external
return (isCategory && isMatch);
      });
    }

    if (data.length < end) {
      end = data.length;
    }

    for (var i = start; i < end; i++) {
      var font = data[i];
      var hasRegular = ($.inArray('regular', font.variants) !== -1);
      var hasLatin = ($.inArray('latin', font.variants) !== -1);
      var subsets = '';

      if (filterType === 'subset' && category !== 'latin') {
        if ($.inArray('latin', font.subsets) !== -1) {
          subsets = ':latin,' + category;
        } else {
          subsets = ':' + category;
        }
      }

      if (hasRegular) {
        fonts.push(font.family + subsets);
      } else {
        fonts.push(font.family + ':' + font.variants[0] + subsets);
      }
    }

    this.setState({matchCount: fonts.length});

    if (fonts.length > 0) {
github avwo / whistle / biz / webui / htdocs / src / js / index.js View on Github external
function compareSelectedNames(src, target) {
  var srcLen = src.length;
  var i;
  for (i = 0; i < srcLen; i++) {
    if ($.inArray(src[i], target) === -1) {
      return false;
    }
  }
  var targetLen = target.length;
  if (srcLen !== targetLen) {
    for (i = 0; i < targetLen; i++) {
      if ($.inArray(target[i], src) === -1) {
        return false;
      }
    }
  }
  return true;
}
github CenterForOpenScience / osf.io / website / static / js / home-page / institutionsPanelPlugin.js View on Github external
var unaffiliated = allInstitutions.filter(function(inst) {
            return $.inArray(inst.id, affiliatedIds) === -1;
        });
github ecomfe / moye / demo / src / ui / Popup.js View on Github external
onShow: function (e) {
                var oldTarget = this.target;
                if (this._disabled) {
                    return;
                }
                var trigger = e.target;
                if (oldTarget && oldTarget !== trigger) {
                    this.hide();
                }
                var $trigger = $(e.target);
                var liveTriggers = this.liveTriggers;
                if (liveTriggers) {
                    var cls = this.options.triggers;
                    while (!$trigger.hasClass(cls)) {
                        if ($.inArray(trigger, this.liveTriggers) !== -1) {
                            break;
                        }
                        trigger = trigger.parent();
                    }
                    if (!$trigger.hasClass(cls)) {
                        return;
                    }
                }
                this.fire('beforeShow', { event: e });
                this.show();
                this.trigger = trigger;
                var bound = this._bound;
                this._timer = setTimeout(function () {
                    $(document).on('click', bound.onHide);
                    $(window).on('resize', bound.onResize);
                }, 0);
github cloudera / hue / desktop / core / src / desktop / js / apps / notebook / result.js View on Github external
function isDateTimeColumn(type) {
      return $.inArray(type, ['timestamp', 'date', 'datetime']) > -1;
    }