Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(options) {
this.options = options;
this.emitter = new Emitter();
this.initBtlApp();
// todo - refactor these in to the app
this.runOnResize();
this.runHighContrastSwitch();
}
it('should select text from non-editable element', () => {
let clip = new ClipboardAction({
emitter: new Emitter(),
container: document.body,
target: document.querySelector('#paragraph')
});
assert.equal(clip.selectedText, clip.target.textContent);
});
});
it('should call event listener', () => {
const emitter = new Emitter();
const container = document.createElement('div');
const ias = new InfiniteAjaxScroll(container, {emitter});
const spy = {
foo() {}
};
cy.spy(spy, 'foo');
ias.on('my-event', spy.foo);
emitter.emit('my-event', 'data1');
emitter.emit('my-event', 'data2');
before(function () {
connect = sinon.stub(io, 'connect');
socket = new Emitter();
connect.returns(socket);
});
watch(element, opt_offset) {
assert(
typeof element === 'string' || isElement(element),
'@param `element` should be string type or DOM Element!'
);
assert(
typeof opt_offset === 'number' ||
typeof opt_offset === 'object' ||
typeof opt_offset === 'undefined',
'@param `opt_offset` should be number or Object or undefined!'
);
let offsetOpt;
const idx = ++this.counter;
const emitter = new TinyEmitter();
const node = evaluate(element);
assert(
isElement(node),
`Couldn't evaluate (${element}) to a valid DOM node`
);
offsetOpt =
typeof opt_offset === 'number'
? { top: opt_offset, bottom: opt_offset }
: mergeOptions(DEFAULT_OFFSET, opt_offset);
Base.Internal.watching[idx] = {
node,
emitter,
offset: offsetOpt,
this.options = { ...DEFAULT_OPTIONS, ...options };
if (!this.options.rootElement) {
this.options.rootElement = document.body;
}
this.i18n = {
...i18n,
...options.i18n
};
this.onDocumentClick = this.onDocumentClick.bind(this);
this.onDocumentKeydown = this.onDocumentKeydown.bind(this);
this.events = new Emitter();
this.publicEvents = new Emitter();
}
constructor(container, options = {}) {
Assert.singleElement(container, 'container');
this.container = $(container)[0];
this.options = extend({}, defaults, options);
this.emitter = new Emitter();
this.scrollContainer = this.options.scrollContainer;
if (this.options.scrollContainer !== window) {
Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');
this.scrollContainer = $(this.options.scrollContainer)[0];
}
this.nextHandler = nextHandler;
if (typeof this.options.next === 'function') {
this.nextHandler = this.options.next;
}
this.binded = false;
this.paused = false;
this.loadOnScroll = this.options.loadOnScroll;
delete options.el;
}
this.options = Object.assign({
mouseMultiplier: 1,
touchMultiplier: 2,
firefoxMultiplier: 15,
keyStep: 120,
preventTouch: false,
unpreventTouchClass: 'hijack-touchmove-allowed',
limitInertia: false
}, options);
if (this.options.limitInertia) this.lethargy = new Lethargy();
this.emitter = new Emitter();
this.event = {
y: 0,
x: 0,
deltaX: 0,
deltaY: 0
};
this.touchStartX = null;
this.touchStartY = null;
this.bodyTouchAction = null;
if (this.options.passive !== undefined) {
this.listenerOptions = { passive: this.options.passive };
}
}
var InfiniteAjaxScroll = function InfiniteAjaxScroll(container, options) {
if ( options === void 0 ) options = {};
Assert.singleElement(container, 'container');
this.container = $(container)[0];
this.options = extend({}, defaults, options);
this.emitter = new Emitter();
this.scrollContainer = this.options.scrollContainer;
if (this.options.scrollContainer !== window) {
Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');
this.scrollContainer = $(this.options.scrollContainer)[0];
}
this.nextHandler = nextHandler;
if (typeof this.options.next === 'function') {
this.nextHandler = this.options.next;
}
this.binded = false;
this.paused = false;
this.pageIndex = 0;
this.pickerVisible = false;
this.options = { ...DEFAULT_OPTIONS, ...options };
if (!this.options.rootElement) {
this.options.rootElement = document.body;
}
this.i18n = {
...i18n,
...options.i18n
};
this.onDocumentClick = this.onDocumentClick.bind(this);
this.onDocumentKeydown = this.onDocumentKeydown.bind(this);
this.events = new Emitter();
this.publicEvents = new Emitter();
}