How to use the jquery.contains 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 ecomfe / esui / src / behavior / Sortable.js View on Github external
function getParentOffset() {
        // Get the offsetParent and cache its position
        this.offsetParent = this.helper.offsetParent();
        var po = this.offsetParent.offset();

        // This is a special case where we need to modify a offset calculated on start,
        // since the following happened:
        // 1. The position of the helper is absolute,
        // so it's position is calculated based on the next positioned parent
        // 2. The actual offset parent is a child of the scroll parent,
        // and the scroll parent isn't the document, which means that
        // the scroll is included in the initial calculation of the offset of the parent,
        // and never recalculated upon drag
        if (this.cssPosition === 'absolute' && this.scrollParent[0] !== this.document[0]
            && $.contains(this.scrollParent[0], this.offsetParent[0])) {
            po.left += this.scrollParent.scrollLeft();
            po.top += this.scrollParent.scrollTop();
        }

        // This needs to be actually done for all browsers, since pageX/pageY includes this information
        // with an ugly IE fix
        if (this.offsetParent[0] === this.document[0].body
            || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === 'html' && $.ui.ie)) {
            po = {top: 0, left: 0};
        }

        return {
            top: po.top + (parseInt(this.offsetParent.css('borderTopWidth'), 10) || 0),
            left: po.left + (parseInt(this.offsetParent.css('borderLeftWidth'), 10) || 0)
        };
github spinnaker / deck / app / scripts / modules / core / src / search / global / globalSearch.spec.js View on Github external
this.searchFieldBlurred = ($blurEvent) => {
      // if the target is outside the global search (e.g. shift+tab), hide the results
      if (!$.contains($element.get(0), $blurEvent.relatedTarget)) {
        this.hideResults();
      }
    };
github MahdiMajidzadeh / bootstrap-v4-rtl / js / src / tooltip.js View on Github external
if (this.config.animation) {
        $(tip).addClass(ClassName.FADE)
      }

      const placement  = typeof this.config.placement === 'function'
        ? this.config.placement.call(this, tip, this.element)
        : this.config.placement

      const attachment = this._getAttachment(placement)
      this.addAttachmentClass(attachment)

      const container = this._getContainer()
      $(tip).data(this.constructor.DATA_KEY, this)

      if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
        $(tip).appendTo(container)
      }

      $(this.element).trigger(this.constructor.Event.INSERTED)

      this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment))

      $(tip).addClass(ClassName.SHOW)

      // If this is a touch-enabled device we add extra
      // empty mouseover listeners to the body's immediate children;
      // only needed because of broken event delegation on iOS
      // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
      if ('ontouchstart' in document.documentElement) {
        $(document.body).children().on('mouseover', null, $.noop)
      }
github acharts / acharts / tests / canvas-spec.js View on Github external
it('测试生成分组',function(){
    drawGrid(canvas.get('width'),canvas.get('height'));
       group  = canvas.addGroup();
       expect(group.isGroup).to.be(true);
       expect(group.get('el')).not.to.be(undefined);
       expect(group.get('node')).not.to.be(undefined);
       expect($.contains(node,group.get('node'))).to.be(true);
  });
github ifrost / afterwriting-labs / test / acceptance / util / memory-check.js View on Github external
checkDomLeaks: function() {
            var errors = [], orphans = [];
            for (var i in $.cache) {
                if ($.cache.hasOwnProperty(i)) {
                    if ($.cache[i].handle && $.cache[i].handle.elem && document !== $.cache[i].handle.elem && !$.contains(document, $.cache[i].handle.elem)) {
                        var orphan = $($.cache[i].handle.elem);
                        var outerHtml = orphan.get(0).outerHTML;
                        var closeTagIndex = outerHtml.indexOf('>');
                        var html = outerHtml.substr(0, closeTagIndex + 1);
                        orphans.push(html);

                        $('body').append(orphan);
                        orphan.off();
                        orphan.remove();
                        orphan = null;
                    }
                }
            }
            
            if (orphans.length) {
                errors.push(orphans.length + ' detached DOM elements found:\n\t* ' + orphans.join('\n\t* '));
github pipe-cd / pipe / docs / themes / docsy / assets / vendor / bootstrap / js / src / tooltip.js View on Github external
show() {
    if ($(this.element).css('display') === 'none') {
      throw new Error('Please use show on visible elements')
    }

    const showEvent = $.Event(this.constructor.Event.SHOW)
    if (this.isWithContent() && this._isEnabled) {
      $(this.element).trigger(showEvent)

      const shadowRoot = Util.findShadowRoot(this.element)
      const isInTheDom = $.contains(
        shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement,
        this.element
      )

      if (showEvent.isDefaultPrevented() || !isInTheDom) {
        return
      }

      const tip   = this.getTipElement()
      const tipId = Util.getUID(this.constructor.NAME)

      tip.setAttribute('id', tipId)
      this.element.setAttribute('aria-describedby', tipId)

      this.setContent()
github nhn / tui.editor / src / js / wysiwygEditor.js View on Github external
isEditorValid() {
    return this.getEditor() && $.contains(this.$editorContainerEl[0].ownerDocument, this.$editorContainerEl[0]);
  }
github waqastudios / inti-foundation / library / vendor / foundation-sites / js / foundation.reveal.js View on Github external
$('body').on('click.zf.reveal', function(e) {
        if (e.target === _this.$element[0] ||
          $.contains(_this.$element[0], e.target) ||
            !$.contains(document, e.target)) { return; }
        _this.close();
      });
    }
github cloudera / hue / desktop / core / src / desktop / js / ko / components / appSwitcher / ko.appSwitcher.js View on Github external
const closeOnClickOutside = event => {
    if (!this.open()) {
      return;
    }
    if (
      $.contains(document, event.target) &&
      !$.contains($('.hue-app-switcher')[0], event.target)
    ) {
      this.open(false);
    }
  };
github Typesetter / Typesetter / include / thirdparty / Bootstrap4 / js / tooltip.js View on Github external
show() {
    if ($(this.element).css('display') === 'none') {
      throw new Error('Please use show on visible elements')
    }

    const showEvent = $.Event(this.constructor.Event.SHOW)
    if (this.isWithContent() && this._isEnabled) {
      $(this.element).trigger(showEvent)

      const shadowRoot = Util.findShadowRoot(this.element)
      const isInTheDom = $.contains(
        shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement,
        this.element
      )

      if (showEvent.isDefaultPrevented() || !isInTheDom) {
        return
      }

      const tip   = this.getTipElement()
      const tipId = Util.getUID(this.constructor.NAME)

      tip.setAttribute('id', tipId)
      this.element.setAttribute('aria-describedby', tipId)

      this.setContent()