How to use the global/document.body function in global

To help you get started, we’ve selected a few global 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 Raynos / value-event / test / dom-delegator.js View on Github external
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')
github mediaelement / mediaelement / src / js / player.js View on Github external
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 &amp;&amp; t.media.setSize) {
				t.media.setSize(parentWidth, newHeight);
			}</audio></video>
github cristipufu / SwiftClient / samples / SwiftClient.Demo / wwwroot / lib / video-js / src / js / player.js View on Github external
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');
  }
github Raynos / dom-delegator / test / dom-remove-event.js View on Github external
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()
    })
github Raynos / value-event / test / event.js View on Github external
setImmediate(function () {
        assert.equal(values.length, 1)
        assert.equal(values[0].some, 'data')

        document.body.removeChild(elem)
        assert.end()
    })
})
github Raynos / dom-delegator / test / html-data-attrs.js View on Github external
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()
    })
})
github Raynos / graphics / mouse.js View on Github external
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)
}
github kigiri / learn / src / lib / event.js View on Github external
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,
github ocharles / pandoc-live / bundle.js View on Github external
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;
        }]);
    }
}
github Raynos / mercury / examples / number-input / browser.js View on Github external
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);