Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-responds-to

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-responds-to - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

.idea/ember-responds-to.iml

7

addon/mixins/debounced-response.js

@@ -1,4 +0,5 @@

import Ember from 'ember';
import Mixin from '@ember/object/mixin';
import { run } from '@ember/runloop';
export default Ember.Mixin.create({
export default Mixin.create({
debounce(handler) {

@@ -14,3 +15,3 @@ return (...args) => {

Ember.run(this, handler, ...args);
run(this, handler, ...args);
});

@@ -17,0 +18,0 @@ }

@@ -1,36 +0,35 @@

import Ember from 'ember';
import Evented from '@ember/object/evented';
import Mixin from '@ember/object/mixin';
var ENTER_CODE = 13;
var listeners = [];
const ENTER_CODE = 13;
let listeners = [];
function noop() { }
if (typeof Ember.$ !== 'undefined') {
// Triggers 'enterKeydown' event and calls 'enterKeydown' on each listener in LIFO order.
// - halts if a handler returns a truthy value
Ember.$(window).on('keydown', this, function (e) {
if (e.which !== ENTER_CODE) return;
listeners.some(listener => {
listener.trigger('enterKeydown');
return listener.enterKeydown();
});
// Triggers 'enterKeydown' event and calls 'enterKeydown' on each listener in LIFO order.
// - halts if a handler returns a truthy value
window.addEventListener('keydown', this, (e) => {
if (e.which !== ENTER_CODE) return;
listeners.some((listener) => {
listener.trigger('enterKeydown');
return listener.enterKeydown();
});
}
});
export default Ember.Mixin.create(
Ember.Evented,
{
export default Mixin.create(
Evented,
{
// @return {boolean} stopPropagation
enterKeydown: noop,
// @return {boolean} stopPropagation
enterKeydown: noop,
didInsertElement: function () {
this._super();
listeners.unshift(this);
},
didInsertElement() {
this._super();
listeners.unshift(this);
},
willClearRender: function () {
this._super();
listeners = listeners.filter(listener => listener !== this);
}
willClearRender() {
this._super();
listeners = listeners.filter(listener => listener !== this);
}
});
});

@@ -1,38 +0,37 @@

import Ember from 'ember';
import Evented from '@ember/object/evented';
import Mixin from '@ember/object/mixin';
var ESC_CODE = 27;
var listeners = [];
const ESC_CODE = 27;
let listeners = [];
function noop() { }
if (typeof Ember.$ !== 'undefined') {
// Triggers 'escKeydown' event and calls 'escKeydown' on each listener in LIFO order.
// - unless target element is a SELECT or INPUT
// - halts if a handler returns a truthy value
Ember.$(window).on('keydown', this, function (e) {
if (e.which !== ESC_CODE) return;
if (['SELECT', 'INPUT'].indexOf(e.target.tagName) > -1) return;
listeners.some(listener => {
listener.trigger('escKeydown');
return listener.escKeydown();
});
// Triggers 'escKeydown' event and calls 'escKeydown' on each listener in LIFO order.
// - unless target element is a SELECT or INPUT
// - halts if a handler returns a truthy value
window.addEventListener('keydown', this, (e) => {
if (e.which !== ESC_CODE) return;
if (['SELECT', 'INPUT'].indexOf(e.target.tagName) > -1) return;
listeners.some((listener) => {
listener.trigger('escKeydown');
return listener.escKeydown();
});
}
});
export default Ember.Mixin.create(
Ember.Evented,
{
export default Mixin.create(
Evented,
{
// @return {boolean} stopPropagation
escKeydown: noop,
// @return {boolean} stopPropagation
escKeydown: noop,
didInsertElement: function () {
this._super();
listeners.unshift(this);
},
didInsertElement() {
this._super();
listeners.unshift(this);
},
willClearRender: function () {
this._super();
listeners = listeners.filter(listener => listener !== this);
}
willClearRender() {
this._super();
listeners = listeners.filter(listener => listener !== this);
}
});
});

@@ -1,4 +0,6 @@

import Ember from 'ember';
import Evented from '@ember/object/evented';
import Mixin from '@ember/object/mixin';
import { run } from '@ember/runloop';
var mediaQueryList;
let mediaQueryList;
function noop() { }

@@ -8,14 +10,14 @@

// Browser support: http://caniuse.com/#feat=matchmedia
export default Ember.Mixin.create(Ember.Evented, {
export default Mixin.create(Evented, {
print: noop,
didInsertElement: function () {
didInsertElement() {
this._super();
mediaQueryList = mediaQueryList || window.matchMedia('print');
this.printHandler = (mql) => this._printHandler(mql);
this.printHandler = mql => this._printHandler(mql);
mediaQueryList.addListener(this.printHandler);
},
willDestroyElement: function () {
willDestroyElement() {
this._super();

@@ -25,6 +27,6 @@ mediaQueryList.removeListener(this.printHandler);

_printHandler: function (mql) {
_printHandler(mql) {
if (this.get('isDestroyed')) return;
if (!mql.matches) return;
Ember.run(() => {
run(() => {
this.trigger('print');

@@ -31,0 +33,0 @@ this.print();

@@ -1,32 +0,37 @@

import Ember from 'ember';
import Evented from '@ember/object/evented';
import DebouncedResponse from './debounced-response';
import Mixin from '@ember/object/mixin';
var RESIZE_EVENTS = 'resize orientationchange';
const RESIZE_EVENTS = 'resize orientationchange';
function noop() { }
// Debounces browser event, triggers 'resize' event and calls 'resize' handler.
export default Ember.Mixin.create(
Ember.Evented,
export default Mixin.create(
Evented,
DebouncedResponse,
{
{
resize: noop,
resize: noop,
didInsertElement: function () {
this._super(...arguments);
didInsertElement() {
this._super(...arguments);
this.resizeHandler = this.debounce((...args) => {
this.trigger('resize', ...args);
this.resize(...args);
});
this.resizeHandler = this.debounce((...args) => {
this.trigger('resize', ...args);
this.resize(...args);
});
Ember.$(window).on(RESIZE_EVENTS, this.resizeHandler);
},
RESIZE_EVENTS.split(' ').forEach((e) => {
window.addEventListener(e, this.resizeHandler, false);
});
},
willDestroyElement: function () {
this._super(...arguments);
willDestroyElement() {
this._super(...arguments);
Ember.$(window).off(RESIZE_EVENTS, this.resizeHandler);
}
RESIZE_EVENTS.split(' ').forEach((e) => {
window.removeEventListener(e, this.resizeHandler, false);
});
},
});
});

@@ -1,3 +0,4 @@

import Ember from 'ember';
import DebouncedResponse from './debounced-response';
import Evented from '@ember/object/evented';
import Mixin from '@ember/object/mixin';

@@ -7,25 +8,24 @@ function noop() { }

// Debounces browser event, triggers 'scroll' event and calls 'scroll' handler.
export default Ember.Mixin.create(
Ember.Evented,
export default Mixin.create(
Evented,
DebouncedResponse,
{
{
scroll: noop,
scroll: noop,
didInsertElement() {
this._super(...arguments);
didInsertElement: function () {
this._super(...arguments);
this.scrollHandler = this.debounce((...args) => {
this.trigger('scroll', ...args);
this.scroll(...args);
});
this.scrollHandler = this.debounce((...args) => {
this.trigger('scroll', ...args);
this.scroll(...args);
});
window.addEventListener('scroll', this.scrollHandler);
},
Ember.$(window).on('scroll', this.scrollHandler);
},
willDestroyElement() {
this._super(...arguments);
willDestroyElement: function () {
this._super(...arguments);
Ember.$(window).off('scroll', this.scrollHandler);
}
});
window.removeEventListener('scroll', this.scrollHandler);
},
});

@@ -0,1 +1,2 @@

/* eslint-env node */
'use strict';

@@ -2,0 +3,0 @@

@@ -1,2 +0,2 @@

/* jshint node: true */
/* eslint-env node */
'use strict';

@@ -3,0 +3,0 @@

{
"name": "ember-responds-to",
"version": "1.4.0",
"version": "1.5.0",
"description": "Ember mixins for browser event handling.",
"keywords": [
"ember-addon",
"responds to",
"events",
"keydown",
"resize",
"scroll"
],
"license": "MIT",
"author": "",
"contributors": [
{
"name": "Robert Wagner",
"email": "rwwagner90@gmail.com",
"url": "https://github.com/rwwagner90"
}
],
"directories": {

@@ -9,46 +26,35 @@ "doc": "doc",

},
"repository": "git://github.com/dollarshaveclub/ember-responds-to.git",
"scripts": {
"start": "ember server",
"build": "ember build",
"lint": "eslint .",
"test": "ember try:testall"
"test": "ember try:each"
},
"repository": "git://github.com/dollarshaveclub/ember-responds-to.git",
"engines": {
"node": ">= 0.10.0"
"dependencies": {
"ember-cli-babel": "^6.8.1"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"ember-cli": "2.12.1",
"broccoli-asset-rev": "^2.4.5",
"ember-cli": "~2.15.0-beta.2",
"ember-cli-app-version": "3.0.0",
"ember-cli-content-security-policy": "^0.6.1",
"ember-cli-dependency-checker": "^1.0.0",
"ember-cli-htmlbars": "1.2.0",
"ember-cli-htmlbars-inline-precompile": "0.3.6",
"ember-cli-ic-ajax": "1.0.0",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "3.1.2",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.0.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-test-loader": "^2.1.0",
"ember-cli-uglify": "^1.0.1",
"ember-data": "2.12.1",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "2.0.0",
"ember-cli-uglify": "^2.0.0-beta.1",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.1.0",
"ember-sinon": "0.7.0",
"ember-source": "^2.12.1",
"eslint": "3.19.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-dollarshaveclub": "^1.0.0",
"ember-native-dom-event-dispatcher": "^0.6.3",
"ember-native-dom-helpers": "^0.5.4",
"ember-resolver": "^4.0.0",
"ember-sinon": "1.0.0",
"ember-source": "~2.15.0-beta.3",
"loader.js": "^4.2.3"
},
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.1.6"
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
},

@@ -55,0 +61,0 @@ "ember-addon": {

# Ember-responds-to
[![npm version](https://badge.fury.io/js/ember-responds-to.svg)](http://badge.fury.io/js/ember-responds-to)
[![npm](https://img.shields.io/npm/dm/ember-responds-to.svg)]()
[![Ember Observer Score](https://emberobserver.com/badges/ember-responds-to.svg)](https://emberobserver.com/addons/ember-responds-to)
[![Build Status](https://travis-ci.org/dollarshaveclub/ember-responds-to.svg?branch=master)](https://travis-ci.org/dollarshaveclub/ember-responds-to)
This [Ember CLI](http://www.ember-cli.com/) addon makes it easy to handle browser events in your components.

@@ -26,3 +31,3 @@

```javascript
import Ember from 'ember';
import Component from '@ember/component';
import RespondsToEnterKeydown from 'ember-responds-to/mixins/responds-to-enter-keydown';

@@ -33,5 +38,4 @@ import RespondsToEscKeydown from 'ember-responds-to/mixins/responds-to-esc-keydown';

import RespondsToPrint from 'ember-responds-to/mixins/responds-to-print';
import { on } from '@ember/object/evented';
const {Component, on} = Ember;
export default Component.extend(

@@ -38,0 +42,0 @@ RespondsToEnterKeydown,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc