Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
};
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();
}
};
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)
}
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);
});
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* '));
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()
isEditorValid() {
return this.getEditor() && $.contains(this.$editorContainerEl[0].ownerDocument, this.$editorContainerEl[0]);
}
$('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();
});
}
const closeOnClickOutside = event => {
if (!this.open()) {
return;
}
if (
$.contains(document, event.target) &&
!$.contains($('.hue-app-switcher')[0], event.target)
) {
this.open(false);
}
};
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()