device-manager
Advanced tools
Comparing version 1.0.7 to 1.1.1
{ | ||
"name": "device-manager", | ||
"version": "1.0.7", | ||
"version": "1.1.1", | ||
"homepage": "https://github.com/mkay581/device-manager", | ||
@@ -26,3 +26,6 @@ "authors": [ | ||
"tests" | ||
] | ||
], | ||
"dependencies": { | ||
"listen-js": "^1.0.1" | ||
} | ||
} |
/** | ||
* device-manager - v1.0.7. | ||
* device-manager - v1.1.1. | ||
* https://github.com/mkay581/device-manager.git | ||
@@ -7,2 +7,2 @@ * Copyright 2015 Mark Kennedy. Licensed MIT. | ||
!function t(e,n,r){function i(s,o){if(!n[s]){if(!e[s]){var h="function"==typeof require&&require;if(!o&&h)return h(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var g=n[s]={exports:{}};e[s][0].call(g.exports,function(t){var n=e[s][1][t];return i(n?n:t)},g,g.exports,t,e,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e){"use strict";var n={createTarget:function(t){this._targets=this._targets||[];var e=this._getTargetMap(t);e.target||(t.addEventListener=this._getEventMethod(t,"_addEvent").bind(this),t.removeEventListener=this._getEventMethod(t,"_removeEvent").bind(this),t.dispatchEvent=this._getEventMethod(t,"_dispatchEvent").bind(this),e.target=t,this._targets.push(e))},_getTargetMap:function(t){return this._targets.filter(function(e){return e.target===t})[0]||{}},_addEvent:function(t,e,n,r,i){"boolean"!=typeof r&&(i=r,r=null),r=r||!1;var a=this.getNested(this._getTargetMap(t),e);a||(a=this.setNested(this._getTargetMap(t),e,[]));var s={listener:n,context:i,useCapture:r};-1===a.indexOf(s)&&a.push(s)},_getEventMethod:function(t,e){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(t),this[e].apply(this,n)}.bind(this)},_removeEvent:function(t,e,n){var r=this.getNested(this._getTargetMap(t),e,[]);r.forEach(function(t,e){t.listener===n&&r.splice(e,1)})},_dispatchEvent:function(t,e,n){var r,i=this._getTargetMap(t)||{};i[e]&&i[e].forEach(function(i){r=this._createEvent(e,n),i.listener.call(i.context||t,r)}.bind(this))},_createEvent:function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n},extend:function(t){var e,n,r=t;for(n=1;n<arguments.length;n++){e=arguments[n];for(var i in e)e.hasOwnProperty(i)&&(r[i]=e[i])}return r},getNested:function(t,e,n){for(var r=e.split("."),i=t,a=0;a<r.length;a++){if(!i[r[a]]){i=n;break}i=i[r[a]]}return i},setNested:function(t,e,n){for(var r=e.split("."),i=t,a=0;a<r.length;a++){var s=a===r.length-1;s?i[r[a]]=n:(i[r[a]]=i[r[a]]||{},i=i[r[a]])}return n},destroyTarget:function(t){var e=this._getTargetMap(t),n=this._targets.indexOf(e);n>-1&&this._targets.splice(n,1)}};e.exports=n},{}],2:[function(t,e){"use strict";var n=t("./../external/event-handler/src/event-handler"),r=function(){this.initialize()};r.prototype={initialize:function(){n.createTarget(this),this._getOrientationChangeListener=function(){var t=this;return function(){t._onOrientationChange.bind(t)}},window.addEventListener("orientationchange",this._getOrientationChangeListener())},_onOrientationChange:function(){var t;t=window.innerHeight<=window.innerWidth?"landscape":"portrait",this.dispatchEvent("orientationchange",{orientation:t})},getUserAgent:function(){return window.navigator.userAgent},isBrowser:function(t){var e,n=t,r=this.getUserAgent();return t?(Array.isArray(t)&&(n=t.join("|")),n.indexOf("safari")>-1?(e=new RegExp("chrome","i"),!e.test(r)):(e=new RegExp(n,"i"),e.test(r))):!0},isMobile:function(){return this.isBrowser(["Android","webOS","iPhone","iPad","iPod","BlackBerry","IEMobile","Opera Mini"])},isOS:function(t){var e=t;Array.isArray(t)&&(e=t.join("|"));var n=new RegExp(e,"i");return n.test(this.getUserAgent())},destroy:function(){window.removeEventListener("orientationchange",this._getOrientationChangeListener()),n.destroyTarget(this)}},e.exports=new r},{"./../external/event-handler/src/event-handler":1}]},{},[2]); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.DeviceManager=t()}}(function(){return function t(e,n,i){function r(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return r(n?n:t)},h,h.exports,t,e,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(t,e,n){"use strict";var i={createTarget:function(t){this._targets=this._targets||[];var e=this._getTargetMap(t);e.target||(t.addEventListener=this._getEventMethod(t,"_addEvent").bind(this),t.removeEventListener=this._getEventMethod(t,"_removeEvent").bind(this),t.dispatchEvent=this._getEventMethod(t,"_dispatchEvent").bind(this),e.target=t,this._targets.push(e))},_getTargetMap:function(t){return this._targets.filter(function(e){return e.target===t})[0]||{}},_addEvent:function(t,e,n,i,r){"boolean"!=typeof i&&(r=i,i=null),i=i||!1;var o=this.getNested(this._getTargetMap(t),e);o||(o=this.setNested(this._getTargetMap(t),e,[]));var s={listener:n,context:r,useCapture:i};-1===o.indexOf(s)&&o.push(s)},_getEventMethod:function(t,e){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(t),this[e].apply(this,n)}.bind(this)},_removeEvent:function(t,e,n){var i=this.getNested(this._getTargetMap(t),e,[]);i.forEach(function(t,e){t.listener===n&&i.splice(e,1)})},_dispatchEvent:function(t,e,n){var i,r=this._getTargetMap(t)||{};r[e]&&r[e].forEach(function(r){i=this._createEvent(e,n),r.listener.call(r.context||t,i)}.bind(this))},_createEvent:function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n},extend:function(t){var e,n,i=t;for(n=1;n<arguments.length;n++){e=arguments[n];for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r])}return i},getNested:function(t,e,n){for(var i=e.split("."),r=t,o=0;o<i.length;o++){if(!r[i[o]]){r=n;break}r=r[i[o]]}return r},setNested:function(t,e,n){for(var i=e.split("."),r=t,o=0;o<i.length;o++){var s=o===i.length-1;s?r[i[o]]=n:(r[i[o]]=r[i[o]]||{},r=r[i[o]])}return n},destroyTarget:function(t){var e=this._getTargetMap(t),n=this._targets.indexOf(e);n>-1&&this._targets.splice(n,1)}};e.exports=i},{}],2:[function(t,e,n){"use strict";var i=t("listen-js"),r=function(){this.initialize()};r.prototype={initialize:function(){i.createTarget(this),this._getOrientationChangeListener=function(){var t=this;return function(){t._onOrientationChange.bind(t)}},window.addEventListener("orientationchange",this._getOrientationChangeListener())},_onOrientationChange:function(){var t;t=window.innerHeight<=window.innerWidth?"landscape":"portrait",this.dispatchEvent("orientationchange",{orientation:t})},getUserAgent:function(){return window.navigator.userAgent},isBrowser:function(t){var e,n=t,i=this.getUserAgent();return t?(Array.isArray(t)&&(n=t.join("|")),n.indexOf("safari")>-1?(e=new RegExp("chrome","i"),!e.test(i)):(e=new RegExp(n,"i"),e.test(i))):!0},isMobile:function(){return this.isBrowser(["Android","webOS","iPhone","iPad","iPod","BlackBerry","IEMobile","Opera Mini"])},isOS:function(t){var e=t;Array.isArray(t)&&(e=t.join("|"));var n=new RegExp(e,"i");return n.test(this.getUserAgent())},destroy:function(){window.removeEventListener("orientationchange",this._getOrientationChangeListener()),i.destroyTarget(this)}},e.exports=new r},{"listen-js":1}]},{},[2])(2)}); |
/** | ||
* device-manager - v1.0.7. | ||
* device-manager - v1.1.1. | ||
* https://github.com/mkay581/device-manager.git | ||
@@ -7,3 +7,3 @@ * Copyright 2015 Mark Kennedy. Licensed MIT. | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.DeviceManager = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -13,6 +13,6 @@ /** | ||
around any object or function, so that it can begin to receive and trigger event listeners. | ||
@class EventHandler | ||
@class Listen | ||
*/ | ||
var EventHandler = { | ||
var Listen = { | ||
@@ -88,3 +88,3 @@ /** | ||
* @param method | ||
* @returns {*|function(this:EventHandler)} | ||
* @returns {*|function(this:Listen)} | ||
*/ | ||
@@ -220,7 +220,7 @@ _getEventMethod: function (target, method) { | ||
module.exports = EventHandler; | ||
module.exports = Listen; | ||
},{}],2:[function(require,module,exports){ | ||
'use strict'; | ||
var EventHandler = require('./../external/event-handler/src/event-handler'); | ||
var Listen = require('listen-js'); | ||
/** | ||
@@ -242,3 +242,3 @@ @class DeviceManager | ||
// allow event listening on the device | ||
EventHandler.createTarget(this); | ||
Listen.createTarget(this); | ||
@@ -333,3 +333,3 @@ this._getOrientationChangeListener = function () { | ||
window.removeEventListener('orientationchange', this._getOrientationChangeListener()); | ||
EventHandler.destroyTarget(this); | ||
Listen.destroyTarget(this); | ||
} | ||
@@ -340,2 +340,3 @@ | ||
module.exports = new DeviceManager(); | ||
},{"./../external/event-handler/src/event-handler":1}]},{},[2]); | ||
},{"listen-js":1}]},{},[2])(2) | ||
}); |
@@ -6,2 +6,4 @@ module.exports = function(grunt) { | ||
pkg: grunt.file.readJSON("package.json"), | ||
bt: { | ||
@@ -22,2 +24,5 @@ dist: 'dist', | ||
}, | ||
banner: { | ||
files: ['dist/*'] | ||
}, | ||
tests: { | ||
@@ -28,18 +33,8 @@ mocha: { | ||
} | ||
}, | ||
copy: { | ||
main: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: 'node_modules/event-handler', | ||
src: ['**'], | ||
dest: 'external/event-handler/' | ||
} | ||
] | ||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('build-tools'); | ||
require("load-grunt-tasks")(grunt); | ||
grunt.loadNpmTasks('build-tools'); | ||
}; |
{ | ||
"name": "device-manager", | ||
"version": "1.0.7", | ||
"version": "1.1.1", | ||
"description": "Detect information about a user's current device", | ||
@@ -12,2 +12,3 @@ "repository": { | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
@@ -23,5 +24,4 @@ "name": "Mark Kennedy", | ||
"devDependencies": { | ||
"build-tools": "^1.3.2", | ||
"grunt": "^0.4.5", | ||
"grunt-build-tools": "^1.1.1", | ||
"grunt-contrib-copy": "^0.8.0", | ||
"load-grunt-tasks": "^3.1.0", | ||
@@ -34,4 +34,4 @@ "sinon": "^1.14.1" | ||
"dependencies": { | ||
"event-handler": "^1.0.0" | ||
"listen-js": "^1.0.1" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/mkay581/device-manager.svg?branch=master)](https://travis-ci.org/mkay581/device-manager) | ||
# Device Manager | ||
@@ -28,2 +30,3 @@ | ||
``` | ||
``` | ||
'use strict'; | ||
var EventHandler = require('./../external/event-handler/src/event-handler'); | ||
var Listen = require('listen-js'); | ||
/** | ||
@@ -20,3 +20,3 @@ @class DeviceManager | ||
// allow event listening on the device | ||
EventHandler.createTarget(this); | ||
Listen.createTarget(this); | ||
@@ -111,3 +111,3 @@ this._getOrientationChangeListener = function () { | ||
window.removeEventListener('orientationchange', this._getOrientationChangeListener()); | ||
EventHandler.destroyTarget(this); | ||
Listen.destroyTarget(this); | ||
} | ||
@@ -114,0 +114,0 @@ |
var sinon = require('sinon'); | ||
var assert = require('assert'); | ||
var EventHandler = require('event-handler'); | ||
var Listen = require('listen-js'); | ||
@@ -9,4 +9,4 @@ describe('Device Manager', function (){ | ||
var userAgentMock = ''; | ||
var eventManagerCreateTargetStub = sinon.stub(EventHandler, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(EventHandler, 'destroyTarget'); | ||
var eventManagerCreateTargetStub = sinon.stub(Listen, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(Listen, 'destroyTarget'); | ||
var device = require('./../src/device-manager'); | ||
@@ -25,4 +25,4 @@ var getUserAgentStub = sinon.stub(device, 'getUserAgent').returns(userAgentMock); | ||
'Chrome/18.0.1025.133 Mobile Safari/535.19'; | ||
var eventManagerCreateTargetStub = sinon.stub(EventHandler, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(EventHandler, 'destroyTarget'); | ||
var eventManagerCreateTargetStub = sinon.stub(Listen, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(Listen, 'destroyTarget'); | ||
var device = require('./../src/device-manager'); | ||
@@ -43,4 +43,4 @@ var getUserAgentStub = sinon.stub(device, 'getUserAgent').returns(userAgentMock); | ||
"Chrome/42.0.2311.90 Safari/537.36"; | ||
var eventManagerCreateTargetStub = sinon.stub(EventHandler, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(EventHandler, 'destroyTarget'); | ||
var eventManagerCreateTargetStub = sinon.stub(Listen, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(Listen, 'destroyTarget'); | ||
var device = require('./../src/device-manager'); | ||
@@ -57,4 +57,4 @@ var getUserAgentStub = sinon.stub(device, 'getUserAgent').returns(chromeUserAgentMock); | ||
var userAgentMock = ''; | ||
var eventManagerCreateTargetStub = sinon.stub(EventHandler, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(EventHandler, 'destroyTarget'); | ||
var eventManagerCreateTargetStub = sinon.stub(Listen, 'createTarget'); | ||
var eventManagerDestroyTargetStub = sinon.stub(Listen, 'destroyTarget'); | ||
var device = require('./../src/device-manager'); | ||
@@ -61,0 +61,0 @@ var getUserAgentStub = sinon.stub(device, 'getUserAgent').returns(userAgentMock); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
32
24999
11
524
+ Addedlisten-js@^1.0.1
+ Addedlisten-js@1.0.1(transitive)
- Removedevent-handler@^1.0.0
- Removedevent-handler@1.0.1(transitive)