Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('can add (function) event', function (assert) {
var elem = h('div')
document.body.appendChild(elem)
var values = []
Delegator() // listen to all the things
var fn = function (data) {
values.push(['fn', data])
}
DataSet(elem).click = event(fn, {
some: 'data'
})
var ev = Event('click')
elem.dispatchEvent(ev)
setImmediate(function () {
assert.equal(values.length, 1)
assert.equal(values[0][0], 'fn')
newHeight = parseFloat(parentWidth * nativeHeight / nativeWidth, 10);
} else {
newHeight = t.height >= t.width ? parseFloat(parentWidth / aspectRatio, 10) : parseFloat(parentWidth * aspectRatio, 10);
}
} else {
newHeight = nativeHeight;
}
// If we were unable to compute newHeight, get the container height instead
if (isNaN(newHeight)) {
newHeight = parentHeight;
}
if (t.getElement(t.container).parentNode.length > 0 && t.getElement(t.container).parentNode.tagName.toLowerCase() === 'body') {
parentWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
newHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}
if (newHeight && parentWidth) {
// set outer container size
t.getElement(t.container).style.width = `${parentWidth}px`;
t.getElement(t.container).style.height = `${newHeight}px`;
// set native <video> or <audio> and shims
t.node.style.width = '100%';
t.node.style.height = '100%';
// if shim is ready, send the size to the embedded plugin
if (t.isVideo && t.media.setSize) {
t.media.setSize(parentWidth, newHeight);
}</audio></video>
enterFullWindow() {
this.isFullWindow = true;
// Storing original doc overflow value to return to when fullscreen is off
this.docOrigOverflow = document.documentElement.style.overflow;
// Add listener for esc key to exit fullscreen
Events.on(document, 'keydown', Fn.bind(this, this.fullWindowOnEscKey));
// Hide any scroll bars
document.documentElement.style.overflow = 'hidden';
// Apply fullscreen styles
Dom.addElClass(document.body, 'vjs-full-window');
this.trigger('enterFullWindow');
}
test("removing other listener", function (assert) {
var elem = h("div")
document.body.appendChild(elem)
var d = Delegator()
d.addEventListener(elem, "click", function () {})
assert.doesNotThrow(function () {
d.removeEventListener(elem, "click", function () {})
})
document.body.removeChild(elem)
assert.end()
})
setImmediate(function () {
assert.equal(values.length, 1)
assert.equal(values[0].some, 'data')
document.body.removeChild(elem)
assert.end()
})
})
setImmediate(function () {
assert.ok("bar" in events)
assert.ok("baz" in events)
assert.equal(events.bar.value.type, "baz")
assert.equal(events.baz.value.type, "bar")
document.body.removeChild(elem)
assert.end()
})
})
function getXY(event) {
var posx = 0
var posy = 0
if (!event) {
event = window.event
}
if (event.pageX || event.pageY) {
posx = event.pageX;
posy = event.pageY;
} else if (event.clientX || event.clientY) {
posx = event.clientX + document.body.scrollLeft +
document.documentElement.scrollLeft;
posy = event.clientY + document.body.scrollTop +
document.documentElement.scrollTop;
}
return new Point(posx, posy)
}
const document = require('global/document');
const window = require('global/window');
const observ = require('observ');
const each = require('lib/each');
const loop = require('lib/loop');
const base = document.documentElement;
const mouseState = {
hover: document.body,
x: 0,
y: 0,
m: false,
r: false,
l: false,
}
const mouseKeys = {
1:'l',
2:'m',
3:'r',
}
const domState = {
top: 0,
width: 0,
evtSource.onmessage = function(e) {
i ++;
var vnode = virtualize.fromHTML("<div>" + e.data.replace(/\\n/g, "\n") + "</div>");
var domNode = createElement(vnode);
var hidden = createElement(
h('div', {
style: {
visibility: "hidden",
position: "absolute",
top: "0"
}
})
);
document.body.appendChild(hidden);
hidden.appendChild(domNode);
MathJax.Hub.Queue(["Typeset", MathJax.Hub, hidden, function() {
var newTree = virtualize(hidden.firstChild);
var patches = diff(lastVnode, newTree);
root = patch(root, patches);
document.getElementsByTagName('html')[0].scrollTop = root.scrollHeight;
lastVnode = newTree;
}]);
}
}
App.render = function render(state) {
function numberspanny(name, numberInput) {
return h('span', [
name,
NumberInput.render(numberInput)
]);
}
return h('div', [
numberspanny('red', state.red),
numberspanny('blue', state.blue),
numberspanny('green', state.green)
]);
};
hg.app(document.body, App(), App.render);