export default ()=>{
    const IE9_Chrome_Safari_Opera_Scroll = K.fromEvents(window, 'mousewheel');
    const Firefox_Scroll = K.fromEvents(window, 'DOMMouseScroll');
    
    return IE9_Chrome_Safari_Opera_Scroll
    .merge(Firefox_Scroll)
    .map(crossBrowserHack)
}
Example #2
0
/** @ngInject */
function VideoBackgroundDirective($rootScope, Settings, safeApply) {
  var focused = Kefir.merge([
    Kefir.fromEvents(window, 'focus').map(() => true),
    Kefir.fromEvents(window, 'blur').map(() => false),
  ]);

  return {
    restrict: 'E',
    scope: {},
    template: VIDEO_HTML,

    link: function (scope) {
      scope.showVideo = false;
      scope.pageFocused = true;

      focused.onValue((isFocused) => {
        safeApply(scope, () => {
          if (!scope.pageFocused && isFocused) {
            scope.videoReady = false;
          }

          scope.pageFocused = isFocused;
        });
      });

      // use ng-show to prevent a black flash from displaying
      // an unloaded video when the videoBackground setting changes
      scope.videoReady = false;
      scope.canPlay = () => scope.videoReady = true;

      function syncSettings() {
        Settings.getSettings((settings) => {
          scope.showVideo = (settings.videoBackground === 'on');
          if (!scope.showVideo) {
            scope.videoReady = false;
          }
        });
      }

      var handler = $rootScope.$on('settings-updated', syncSettings);
      scope.$on('$destroy', handler);
    },
  };
}
Example #3
0
function makeHistory () {
  let bus = createBus()
  let popstate = K.fromEvents(window, 'hashchange', getCurrentState)
  let stream = K.merge([bus.stream, popstate])
              .toProperty(getCurrentState)
  let stateData = {}
  return {
    stream,
    push ({path, data}) {
      data = extend(stateData, data)
      bus.push({path, data})
      window.location.hash = path
    },
  }

  function getCurrentState () {
    let path = window.location.hash.substr(1)
    return {path, data: stateData}
  }
}
Example #4
0
  componentDidMount() {
    const isEnterOrArrowKey = e =>
      (e.which === 13) || (37 <= e.which && e.which <= 40);
    const el = this._elRef.current;
    /*:: if (!el) throw new Error(); */

    // The only things that should receive keydown/keypress events before us
    // are our children. This allows a MenuItem to contain a text input
    // which selectively stops propagation on key events for example.
    Kefir.merge([
      Kefir.fromEvents(window, 'keydown').filter(isEnterOrArrowKey)
        .filter(e => el.contains(e.target)),
      fromEventsCapture(window, 'keydown').filter(isEnterOrArrowKey)
        .filter(e => !el.contains(e.target))
    ])
      .takeUntilBy(this._stopper)
      .onValue(event => this._key(event));

    const parentCtx = this._parentCtx();
    if (parentCtx) {
      parentCtx.registerMenuList(this);
    }
  }
Example #5
0
	function s (ev) {
		return Kefir.fromEvents(dispatcher, ev)
  }
Example #6
0
function streamAndEmitF () {
  let emitter = new EventEmitter()
  let emitF = (x) => emitter.emit('e', x)
  let stream = Kefir.fromEvents(emitter, 'e')
  return [stream, emitF]
}
Example #7
0
var Kefir = require('kefir'),
    Promise = require('bluebird'),
    _ = require('lodash'),
    $ = require('jquery'),
    $ajax = require('./ajax'),
    autocomplete = require('./autocomplete'),

    headerClicks = Kefir.fromEvents(document.querySelector('#model-table > thead'), 'click').map(function (e) {
        return e.target;
    }),
    saveClicks = Kefir.fromEvents(document.querySelector('#save-btn'), 'click'),
    cellClicks = Kefir.fromEvents(document.querySelector('#model-table > tbody'), 'click').map(function (e) {
        return e.target;
    }).filter(function (el) {
        var stateValues = fsm.stateValues() || {};
        return el.getAttribute('data-field') !== stateValues.column;
    }),

    fsm = require('./fsm')({
        states: ['SHOW', 'EDIT', 'SAVE'],
        initial: 'SHOW'
    }),

    oldValues = {};

function inputFocus() {
    var stateValues = fsm.stateValues() || {};
    autocomplete.show(this, stateValues.column);
}

function defInterface() {
Example #8
0
module.exports = (log) => {
  // hyperlog data cb is (err, cb)
  // so we can use that kefir fromStream on the log
  return Kefir.fromEvents(log.createReadStream({live: true}), 'data')
}