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

vue-notifications

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-notifications - npm Package Compare versions

Comparing version 0.7.5 to 0.7.6

2

bower.json
{
"name": "vue-notifications",
"version": "0.7.5",
"version": "0.7.6",
"description": "Vuejs notifications",

@@ -5,0 +5,0 @@ "main": "dist/vue-notifications.js",

@@ -12,2 +12,4 @@ ;(function(root, factory) {

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var PLUGIN_NAME = 'VueNotifications';

@@ -187,6 +189,14 @@ var PACKAGE_NAME = 'vue-notifications';

if (watch && watch()) innerMethods.showInlineFn(elem, message, classes);
var interval = setInterval(function () {
if (watch && !watch()) {
clearInterval(interval);
innerMethods.clearInlineFn.call(innerMethods, elem, classes);
// const interval = setInterval(() => {
var prev = void 0;
var cur = void 0;
setInterval(function () {
if (watch) {
cur = watch();
// clearInterval(interval)
if (cur !== prev) {
if (cur) innerMethods.showInlineFn.call(innerMethods, elem, message, classes);
if (!cur) innerMethods.clearInlineFn.call(innerMethods, elem, classes);
prev = cur;
}
}

@@ -223,7 +233,5 @@ }, 50);

var result = {};
var keepFnFields = ['cb', 'watch'];
Object.keys(config).forEach(function (field) {
keepFnFields.forEach(function (fnField) {

@@ -328,5 +336,80 @@ if (field === fnField) {

vueApp.$emit(PACKAGE_NAME + '-initiated');
},
/**
* @param {Object} vueApp
* @param {Object} notifications
*/
launchWatchableNotifications: function launchWatchableNotifications(vueApp, notifications) {
if (!notifications) return;
Object.keys(notifications).forEach(function (name) {
if (vueApp[name] && notifications[name].watch) {
vueApp[name]();
}
});
vueApp.$emit(PACKAGE_NAME + '-launched_watchable');
},
/**
* @param {Object} vueApp
* @param {Object} notifications
*/
unlinkVueNotificationPlugin: function unlinkVueNotificationPlugin(vueApp, notifications) {
if (!notifications) return;
var attachedMethods = vueApp.$options.methods;
Object.keys(notifications).forEach(function (name) {
if (attachedMethods[name]) {
attachedMethods[name] = undefined;
delete attachedMethods[name];
}
});
vueApp.$emit(PACKAGE_NAME + '-unlinked');
}
};
/**
* @param {Function} Vue
* @param {Object} pluginOptions
* @return {Object}
*/
function makeMixin(Vue, pluginOptions) {
var _ref5;
var hooks = {
init: '',
destroy: 'beforeDestroy',
mounted: ''
};
if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) {
hooks.init = 'init';
hooks.mounted = 'compiled';
}
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) {
hooks.init = 'beforeCreate';
hooks.mounted = 'mounted';
}
return _ref5 = {}, _defineProperty(_ref5, hooks.init, function () {
var vueApp = this;
var vueAppOptions = this.$options;
var notificationsField = vueAppOptions[VueNotifications.propertyName];
innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions);
}), _defineProperty(_ref5, hooks.mounted, function () {
var vueApp = this;
var vueAppOptions = this.$options;
var notificationsField = vueAppOptions[VueNotifications.propertyName];
innerMethods.launchWatchableNotifications(vueApp, notificationsField);
}), _defineProperty(_ref5, hooks.destroy, function () {
var vueApp = this;
var vueAppOptions = this.$options;
var notificationsField = vueAppOptions[VueNotifications.propertyName];
innerMethods.unlinkVueNotificationPlugin(vueApp, notificationsField);
}), _ref5;
}
var VueNotifications = {

@@ -349,18 +432,6 @@ type: TYPE,

var mixin = {};
var hook = void 0;
if (this.installed) throw console.error(MESSAGES.alreadyInstalled);
if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) hook = 'init';
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) hook = 'beforeCreate';
var mixin = makeMixin(Vue, pluginOptions);
Vue.mixin(mixin);
mixin[hook] = function () {
var vueApp = this;
var vueAppOptions = this.$options;
var notificationsField = vueAppOptions[VueNotifications.propertyName];
innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions);
};
Vue.mixin(mixin);
innerMethods.addMethods(this, this.type, pluginOptions);

@@ -367,0 +438,0 @@

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

!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?module.exports=n():e.VueNotifications=n()}(this,function(){"use strict";var e="VueNotifications",n="vue-notifications",s="notifications",t={error:"error",warn:"warn",info:"info",success:"success"},o={evangelion:1,ghostInTheShell:2},i={alreadyInstalled:e+": plugin already installed",methodNameConflict:e+": names conflict - "},a={getVersion:function(e){var n=e.version.match(/(\d+)/g);return{major:+n[0],regular:+n[1],minor:+n[2]}},showInConsole:function(e,n,s){n===s.error?console.error(e):n===s.warn?console.warn(e):n===s.success?console.info(e):console.log(e)},showDefaultMessage:function(e){var n=e.type,s=e.message,o=e.title,i=e.debugMsg,l="Title: "+o+", Message: "+s+", DebugMsg: "+i+", type: "+n;return a.showInConsole(l,n,t),l},addClass:function(e,n){e.classList?e.classList.add(n):e.className+=" "+n},removeClass:function(e,n){e.classList?e.classList.remove(n):e.className=e.className.replace(new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi")," ")},hasClass:function(e,n){return e.classList?e.classList.contains(n):new RegExp("(^| )"+n+"( |$)","gi").test(e.className)},showInlineFn:function(e,n,s){var t=s.inClass,o=s.outClass;e.innerText=n,t&&(a.hasClass(e,t)||a.addClass(e,t)),o&&a.hasClass(e,o)&&a.removeClass(e,o)},clearInlineFn:function(e,n){var s=n.inClass,t=n.outClass;s&&a.hasClass(e,s)&&a.removeClass(e,s),t&&(a.hasClass(e,t)||a.addClass(e,t)),e.innerText=""},showInlineMessage:function(e,n){var s=e.id,o=e.type,i=e.timeout,l=e.message,r=e.classes,c=void 0===r?{}:r,u=e.watch,f=e.debugMsg,d=e.cb;f&&a.showInConsole(f,o,t);var h=document.getElementById(s);return u&&!function(){i=!1,u&&u()&&a.showInlineFn(h,l,c);var e=setInterval(function(){u&&!u()&&(clearInterval(e),a.clearInlineFn.call(a,h,c))},50)}(),u||(a.showInlineFn(h,l,c),setTimeout(function(){a.clearInlineFn.call(n,h,c)},i)),d&&d.call(n,h,function(){return a.clearInlineFn.call(a,h,c)}),l},getValues:function(e,n){var s={},t=["cb","watch"];return Object.keys(n).forEach(function(o){t.forEach(function(t){o===t?s[o]=n[o].bind(e):s[o]="function"==typeof n[o]?n[o].call(e):n[o]})}),s},showMessage:function(e,n,s){var t=a.getValues(s,e),o=!!t.id;if(o)a.showInlineMessage(t,s);else{var i=n&&n[t.type],l=i?n[t.type]:a.showDefaultMessage;l(t,s)}if(e.cb)return e.cb()},addMethods:function(e,n,s){Object.keys(n).forEach(function(t){e[n[t]]=function(e){return e.type=n[t],a.showMessage(e,s)}})},setMethod:function(e,n,s,t){s.methods||(s.methods={}),s.methods[n]?console.error(i.methodNameConflict+n):s.methods[n]=a.makeMethod(e,n,s,t)},makeMethod:function(e,n,s,t){return function(o){var i={};return Object.assign(i,l.config),Object.assign(i,s[l.propertyName][n]),Object.assign(i,o),a.showMessage(i,t,e)}},initVueNotificationPlugin:function(e,s,t){s&&(Object.keys(s).forEach(function(n){a.setMethod(e,n,e.$options,t)}),e.$emit(n+"-initiated"))}},l={type:t,propertyName:s,config:{type:t.info,timeout:3e3},installed:!1,install:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s={},t=void 0;if(this.installed)throw console.error(i.alreadyInstalled);a.getVersion(e).major===o.evangelion&&(t="init"),a.getVersion(e).major===o.ghostInTheShell&&(t="beforeCreate"),s[t]=function(){var e=this,s=this.$options,t=s[l.propertyName];a.initVueNotificationPlugin(e,t,n)},e.mixin(s),a.addMethods(this,this.type,n),this.installed=!0}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(l),l});
!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?module.exports=n():e.VueNotifications=n()}(this,function(){"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function n(n,t){var o,i={init:"",destroy:"beforeDestroy",mounted:""};return r.getVersion(n).major===a.evangelion&&(i.init="init",i.mounted="compiled"),r.getVersion(n).major===a.ghostInTheShell&&(i.init="beforeCreate",i.mounted="mounted"),o={},e(o,i.init,function(){var e=this,n=this.$options,o=n[l.propertyName];r.initVueNotificationPlugin(e,o,t)}),e(o,i.mounted,function(){var e=this,n=this.$options,t=n[l.propertyName];r.launchWatchableNotifications(e,t)}),e(o,i.destroy,function(){var e=this,n=this.$options,t=n[l.propertyName];r.unlinkVueNotificationPlugin(e,t)}),o}var t="VueNotifications",o="vue-notifications",i="notifications",s={error:"error",warn:"warn",info:"info",success:"success"},a={evangelion:1,ghostInTheShell:2},c={alreadyInstalled:t+": plugin already installed",methodNameConflict:t+": names conflict - "},r={getVersion:function(e){var n=e.version.match(/(\d+)/g);return{major:+n[0],regular:+n[1],minor:+n[2]}},showInConsole:function(e,n,t){n===t.error?console.error(e):n===t.warn?console.warn(e):n===t.success?console.info(e):console.log(e)},showDefaultMessage:function(e){var n=e.type,t=e.message,o=e.title,i=e.debugMsg,a="Title: "+o+", Message: "+t+", DebugMsg: "+i+", type: "+n;return r.showInConsole(a,n,s),a},addClass:function(e,n){e.classList?e.classList.add(n):e.className+=" "+n},removeClass:function(e,n){e.classList?e.classList.remove(n):e.className=e.className.replace(new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi")," ")},hasClass:function(e,n){return e.classList?e.classList.contains(n):new RegExp("(^| )"+n+"( |$)","gi").test(e.className)},showInlineFn:function(e,n,t){var o=t.inClass,i=t.outClass;e.innerText=n,o&&(r.hasClass(e,o)||r.addClass(e,o)),i&&r.hasClass(e,i)&&r.removeClass(e,i)},clearInlineFn:function(e,n){var t=n.inClass,o=n.outClass;t&&r.hasClass(e,t)&&r.removeClass(e,t),o&&(r.hasClass(e,o)||r.addClass(e,o)),e.innerText=""},showInlineMessage:function(e,n){var t=e.id,o=e.type,i=e.timeout,a=e.message,c=e.classes,l=void 0===c?{}:c,u=e.watch,f=e.debugMsg,d=e.cb;f&&r.showInConsole(f,o,s);var h=document.getElementById(t);return u&&!function(){i=!1,u&&u()&&r.showInlineFn(h,a,l);var e=void 0,n=void 0;setInterval(function(){u&&(n=u(),n!==e&&(n&&r.showInlineFn.call(r,h,a,l),n||r.clearInlineFn.call(r,h,l),e=n))},50)}(),u||(r.showInlineFn(h,a,l),setTimeout(function(){r.clearInlineFn.call(n,h,l)},i)),d&&d.call(n,h,function(){return r.clearInlineFn.call(r,h,l)}),a},getValues:function(e,n){var t={},o=["cb","watch"];return Object.keys(n).forEach(function(i){o.forEach(function(o){i===o?t[i]=n[i].bind(e):t[i]="function"==typeof n[i]?n[i].call(e):n[i]})}),t},showMessage:function(e,n,t){var o=r.getValues(t,e),i=!!o.id;if(i)r.showInlineMessage(o,t);else{var s=n&&n[o.type],a=s?n[o.type]:r.showDefaultMessage;a(o,t)}if(e.cb)return e.cb()},addMethods:function(e,n,t){Object.keys(n).forEach(function(o){e[n[o]]=function(e){return e.type=n[o],r.showMessage(e,t)}})},setMethod:function(e,n,t,o){t.methods||(t.methods={}),t.methods[n]?console.error(c.methodNameConflict+n):t.methods[n]=r.makeMethod(e,n,t,o)},makeMethod:function(e,n,t,o){return function(i){var s={};return Object.assign(s,l.config),Object.assign(s,t[l.propertyName][n]),Object.assign(s,i),r.showMessage(s,o,e)}},initVueNotificationPlugin:function(e,n,t){n&&(Object.keys(n).forEach(function(n){r.setMethod(e,n,e.$options,t)}),e.$emit(o+"-initiated"))},launchWatchableNotifications:function(e,n){n&&(Object.keys(n).forEach(function(t){e[t]&&n[t].watch&&e[t]()}),e.$emit(o+"-launched_watchable"))},unlinkVueNotificationPlugin:function(e,n){if(n){var t=e.$options.methods;Object.keys(n).forEach(function(e){t[e]&&(t[e]=void 0,delete t[e])}),e.$emit(o+"-unlinked")}}},l={type:s,propertyName:i,config:{type:s.info,timeout:3e3},installed:!1,install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.installed)throw console.error(c.alreadyInstalled);var o=n(e,t);e.mixin(o),r.addMethods(this,this.type,t),this.installed=!0}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(l),l});
//# sourceMappingURL=vue-notifications.es5.min.js.map

@@ -27,3 +27,3 @@ const PLUGIN_NAME = 'VueNotifications'

*/
getVersion (Vue) {
getVersion (Vue) {
const version = Vue.version.match(/(\d+)/g)

@@ -42,3 +42,3 @@ return {

*/
showInConsole (msg, type, types) {
showInConsole (msg, type, types) {
if (type === types.error) console.error(msg)

@@ -57,3 +57,3 @@ else if (type === types.warn) console.warn(msg)

*/
showDefaultMessage ({ type, message, title, debugMsg }) {
showDefaultMessage ({ type, message, title, debugMsg }) {
let msg = `Title: ${title}, Message: ${message}, DebugMsg: ${debugMsg}, type: ${type}`

@@ -105,3 +105,3 @@

*/
showInlineFn (elem, message, { inClass, outClass }) {
showInlineFn (elem, message, { inClass, outClass }) {
elem.innerText = message

@@ -121,3 +121,3 @@ if (inClass) {

*/
clearInlineFn (elem, { inClass, outClass }) {
clearInlineFn (elem, { inClass, outClass }) {
if (inClass) {

@@ -145,3 +145,3 @@ if (innerMethods.hasClass(elem, inClass)) innerMethods.removeClass(elem, inClass)

*/
showInlineMessage ({ id, type, timeout, message, classes = {}, watch, debugMsg, cb }, vueApp) {
showInlineMessage ({ id, type, timeout, message, classes = {}, watch, debugMsg, cb }, vueApp) {
// TODO (S.Panfilov) handle class add and remove here

@@ -154,6 +154,14 @@ if (debugMsg) innerMethods.showInConsole(debugMsg, type, TYPE)

if (watch && watch()) innerMethods.showInlineFn(elem, message, classes)
const interval = setInterval(() => {
if (watch && !watch()) {
clearInterval(interval)
innerMethods.clearInlineFn.call(innerMethods, elem, classes)
// const interval = setInterval(() => {
let prev
let cur
setInterval(() => {
if (watch) {
cur = watch()
// clearInterval(interval)
if (cur !== prev) {
if (cur) innerMethods.showInlineFn.call(innerMethods, elem, message, classes)
if (!cur) innerMethods.clearInlineFn.call(innerMethods, elem, classes)
prev = cur
}
}

@@ -184,9 +192,7 @@ }, 50)

*/
getValues (vueApp, config) {
getValues (vueApp, config) {
const result = {}
const keepFnFields = ['cb', 'watch']
Object.keys(config).forEach(field => {
keepFnFields.forEach(fnField => {

@@ -199,3 +205,2 @@ if (field === fnField) {

})
})

@@ -211,4 +216,3 @@

*/
showMessage(config, options, vueApp)
{
showMessage (config, options, vueApp) {
const valuesObj = innerMethods.getValues(vueApp, config)

@@ -226,4 +230,3 @@ const isLinkedToElem = !!valuesObj.id

if (config.cb) return config.cb()
}
,
},

@@ -236,4 +239,3 @@ /**

* */
addMethods(targetObj, typesObj, options)
{
addMethods (targetObj, typesObj, options) {
Object.keys(typesObj).forEach(v => {

@@ -246,4 +248,3 @@ targetObj[typesObj[v]] = function (config) {

})
}
,
},

@@ -256,4 +257,3 @@ /**

*/
setMethod(vueApp, name, options, pluginOptions)
{
setMethod (vueApp, name, options, pluginOptions) {
if (!options.methods) options.methods = {}

@@ -267,4 +267,3 @@

}
}
,
},

@@ -278,4 +277,3 @@ /**

*/
makeMethod(vueApp, configName, options, pluginOptions)
{
makeMethod (vueApp, configName, options, pluginOptions) {
return function (config) {

@@ -289,4 +287,3 @@ const newConfig = {}

}
}
,
},
/**

@@ -297,4 +294,3 @@ * @param {Object} vueApp

*/
initVueNotificationPlugin(vueApp, notifications, pluginOptions)
{
initVueNotificationPlugin (vueApp, notifications, pluginOptions) {
if (!notifications) return

@@ -306,5 +302,80 @@ Object.keys(notifications).forEach(name => {

vueApp.$emit(`${PACKAGE_NAME}-initiated`)
},
/**
* @param {Object} vueApp
* @param {Object} notifications
*/
launchWatchableNotifications (vueApp, notifications) {
if (!notifications) return
Object.keys(notifications).forEach(name => {
if (vueApp[name] && notifications[name].watch) {
vueApp[name]()
}
})
vueApp.$emit(`${PACKAGE_NAME}-launched_watchable`)
},
/**
* @param {Object} vueApp
* @param {Object} notifications
*/
unlinkVueNotificationPlugin (vueApp, notifications) {
if (!notifications) return
const attachedMethods = vueApp.$options.methods
Object.keys(notifications).forEach(name => {
if (attachedMethods[name]) {
attachedMethods[name] = undefined
delete attachedMethods[name]
}
})
vueApp.$emit(`${PACKAGE_NAME}-unlinked`)
}
}
/**
* @param {Function} Vue
* @param {Object} pluginOptions
* @return {Object}
*/
function makeMixin (Vue, pluginOptions) {
let hooks = {
init: '',
destroy: 'beforeDestroy',
mounted: ''
}
if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) {
hooks.init = 'init'
hooks.mounted = 'compiled'
}
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) {
hooks.init = 'beforeCreate'
hooks.mounted = 'mounted'
}
return {
[hooks.init]: function () {
const vueApp = this
const vueAppOptions = this.$options
const notificationsField = vueAppOptions[VueNotifications.propertyName]
innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions)
},
[hooks.mounted]: function () {
const vueApp = this
const vueAppOptions = this.$options
const notificationsField = vueAppOptions[VueNotifications.propertyName]
innerMethods.launchWatchableNotifications(vueApp, notificationsField)
},
[hooks.destroy]: function () {
const vueApp = this
const vueAppOptions = this.$options
const notificationsField = vueAppOptions[VueNotifications.propertyName]
innerMethods.unlinkVueNotificationPlugin(vueApp, notificationsField)
}
}
}
const VueNotifications = {

@@ -325,18 +396,6 @@ type: TYPE,

install (Vue, pluginOptions = {}) {
const mixin = {}
let hook
if (this.installed) throw console.error(MESSAGES.alreadyInstalled)
if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) hook = 'init'
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) hook = 'beforeCreate'
const mixin = makeMixin(Vue, pluginOptions)
Vue.mixin(mixin)
mixin[hook] = function () {
const vueApp = this
const vueAppOptions = this.$options
const notificationsField = vueAppOptions[VueNotifications.propertyName]
innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions)
}
Vue.mixin(mixin)
innerMethods.addMethods(this, this.type, pluginOptions)

@@ -348,6 +407,5 @@

if (typeof window !== 'undefined' && window.Vue
) {
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VueNotifications)
}

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

'use strict';var PLUGIN_NAME='VueNotifications',PACKAGE_NAME='vue-notifications',PROPERTY_NAME='notifications',TYPE={error:'error',warn:'warn',info:'info',success:'success'},VUE_VERSION={evangelion:1,ghostInTheShell:2},MESSAGES={alreadyInstalled:PLUGIN_NAME+': plugin already installed',methodNameConflict:PLUGIN_NAME+': names conflict - '},innerMethods={getVersion:function getVersion(a){var b=a.version.match(/(\d+)/g);return{major:+b[0],regular:+b[1],minor:+b[2]}},showInConsole:function showInConsole(a,b,c){b===c.error?console.error(a):b===c.warn?console.warn(a):b===c.success?console.info(a):console.log(a)},showDefaultMessage:function showDefaultMessage(_ref){var a=_ref.type,b=_ref.message,c=_ref.title,d=_ref.debugMsg,e='Title: '+c+', Message: '+b+', DebugMsg: '+d+', type: '+a;return innerMethods.showInConsole(e,a,TYPE),e},addClass:function addClass(a,b){a.classList?a.classList.add(b):a.className+=' '+b},removeClass:function removeClass(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp('(^|\\b)'+b.split(' ').join('|')+'(\\b|$)','gi'),' ')},hasClass:function hasClass(a,b){return a.classList?a.classList.contains(b):new RegExp('(^| )'+b+'( |$)','gi').test(a.className)},showInlineFn:function showInlineFn(a,b,_ref2){var c=_ref2.inClass,d=_ref2.outClass;a.innerText=b,c&&!innerMethods.hasClass(a,c)&&innerMethods.addClass(a,c),d&&innerMethods.hasClass(a,d)&&innerMethods.removeClass(a,d)},clearInlineFn:function clearInlineFn(a,_ref3){var b=_ref3.inClass,c=_ref3.outClass;b&&innerMethods.hasClass(a,b)&&innerMethods.removeClass(a,b),c&&!innerMethods.hasClass(a,c)&&innerMethods.addClass(a,c),a.innerText=''},showInlineMessage:function showInlineMessage(_ref4,i){var a=_ref4.id,b=_ref4.type,c=_ref4.timeout,d=_ref4.message,_ref4$classes=_ref4.classes,h=void 0===_ref4$classes?{}:_ref4$classes,e=_ref4.watch,f=_ref4.debugMsg,g=_ref4.cb;f&&innerMethods.showInConsole(f,b,TYPE);var j=document.getElementById(a);return e&&function(){c=!1,e&&e()&&innerMethods.showInlineFn(j,d,h);var k=setInterval(function(){e&&!e()&&(clearInterval(k),innerMethods.clearInlineFn.call(innerMethods,j,h))},50)}(),e||(innerMethods.showInlineFn(j,d,h),setTimeout(function(){innerMethods.clearInlineFn.call(i,j,h)},c)),g&&g.call(i,j,function(){return innerMethods.clearInlineFn.call(innerMethods,j,h)}),d},getValues:function getValues(a,b){var c={},d=['cb','watch'];return Object.keys(b).forEach(function(e){d.forEach(function(f){c[e]=e===f?b[e].bind(a):'function'==typeof b[e]?b[e].call(a):b[e]})}),c},showMessage:function showMessage(a,b,c){var d=innerMethods.getValues(c,a),e=!!d.id;if(e)innerMethods.showInlineMessage(d,c);else{var f=b&&b[d.type],g=f?b[d.type]:innerMethods.showDefaultMessage;g(d,c)}return a.cb?a.cb():void 0},addMethods:function addMethods(a,b,c){Object.keys(b).forEach(function(d){a[b[d]]=function(e){return e.type=b[d],innerMethods.showMessage(e,c)}})},setMethod:function setMethod(a,b,c,d){c.methods||(c.methods={}),c.methods[b]?console.error(MESSAGES.methodNameConflict+b):c.methods[b]=innerMethods.makeMethod(a,b,c,d)},makeMethod:function makeMethod(a,b,c,d){return function(e){var f={};return Object.assign(f,VueNotifications.config),Object.assign(f,c[VueNotifications.propertyName][b]),Object.assign(f,e),innerMethods.showMessage(f,d,a)}},initVueNotificationPlugin:function initVueNotificationPlugin(a,b,c){b&&(Object.keys(b).forEach(function(d){innerMethods.setMethod(a,d,a.$options,c)}),a.$emit(PACKAGE_NAME+'-initiated'))}},VueNotifications={type:TYPE,propertyName:PROPERTY_NAME,config:{type:TYPE.info,timeout:3000},installed:!1,install:function install(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c={},d=void 0;if(this.installed)throw console.error(MESSAGES.alreadyInstalled);innerMethods.getVersion(a).major===VUE_VERSION.evangelion&&(d='init'),innerMethods.getVersion(a).major===VUE_VERSION.ghostInTheShell&&(d='beforeCreate'),c[d]=function(){var e=this,f=this.$options,g=f[VueNotifications.propertyName];innerMethods.initVueNotificationPlugin(e,g,b)},a.mixin(c),innerMethods.addMethods(this,this.type,b),this.installed=!0}};'undefined'!=typeof window&&window.Vue&&window.Vue.use(VueNotifications);
'use strict';function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}var PLUGIN_NAME='VueNotifications',PACKAGE_NAME='vue-notifications',PROPERTY_NAME='notifications',TYPE={error:'error',warn:'warn',info:'info',success:'success'},VUE_VERSION={evangelion:1,ghostInTheShell:2},MESSAGES={alreadyInstalled:PLUGIN_NAME+': plugin already installed',methodNameConflict:PLUGIN_NAME+': names conflict - '},innerMethods={getVersion:function getVersion(a){var b=a.version.match(/(\d+)/g);return{major:+b[0],regular:+b[1],minor:+b[2]}},showInConsole:function showInConsole(a,b,c){b===c.error?console.error(a):b===c.warn?console.warn(a):b===c.success?console.info(a):console.log(a)},showDefaultMessage:function showDefaultMessage(_ref){var a=_ref.type,b=_ref.message,c=_ref.title,d=_ref.debugMsg,e='Title: '+c+', Message: '+b+', DebugMsg: '+d+', type: '+a;return innerMethods.showInConsole(e,a,TYPE),e},addClass:function addClass(a,b){a.classList?a.classList.add(b):a.className+=' '+b},removeClass:function removeClass(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp('(^|\\b)'+b.split(' ').join('|')+'(\\b|$)','gi'),' ')},hasClass:function hasClass(a,b){return a.classList?a.classList.contains(b):new RegExp('(^| )'+b+'( |$)','gi').test(a.className)},showInlineFn:function showInlineFn(a,b,_ref2){var c=_ref2.inClass,d=_ref2.outClass;a.innerText=b,c&&!innerMethods.hasClass(a,c)&&innerMethods.addClass(a,c),d&&innerMethods.hasClass(a,d)&&innerMethods.removeClass(a,d)},clearInlineFn:function clearInlineFn(a,_ref3){var b=_ref3.inClass,c=_ref3.outClass;b&&innerMethods.hasClass(a,b)&&innerMethods.removeClass(a,b),c&&!innerMethods.hasClass(a,c)&&innerMethods.addClass(a,c),a.innerText=''},showInlineMessage:function showInlineMessage(_ref4,i){var a=_ref4.id,b=_ref4.type,c=_ref4.timeout,d=_ref4.message,_ref4$classes=_ref4.classes,h=void 0===_ref4$classes?{}:_ref4$classes,e=_ref4.watch,f=_ref4.debugMsg,g=_ref4.cb;f&&innerMethods.showInConsole(f,b,TYPE);var j=document.getElementById(a);return e&&function(){c=!1,e&&e()&&innerMethods.showInlineFn(j,d,h);var k=void 0,l=void 0;setInterval(function(){e&&(l=e(),l!=k&&(l&&innerMethods.showInlineFn.call(innerMethods,j,d,h),!l&&innerMethods.clearInlineFn.call(innerMethods,j,h),k=l))},50)}(),e||(innerMethods.showInlineFn(j,d,h),setTimeout(function(){innerMethods.clearInlineFn.call(i,j,h)},c)),g&&g.call(i,j,function(){return innerMethods.clearInlineFn.call(innerMethods,j,h)}),d},getValues:function getValues(a,b){var c={},d=['cb','watch'];return Object.keys(b).forEach(function(e){d.forEach(function(f){c[e]=e===f?b[e].bind(a):'function'==typeof b[e]?b[e].call(a):b[e]})}),c},showMessage:function showMessage(a,b,c){var d=innerMethods.getValues(c,a),e=!!d.id;if(e)innerMethods.showInlineMessage(d,c);else{var f=b&&b[d.type],g=f?b[d.type]:innerMethods.showDefaultMessage;g(d,c)}return a.cb?a.cb():void 0},addMethods:function addMethods(a,b,c){Object.keys(b).forEach(function(d){a[b[d]]=function(e){return e.type=b[d],innerMethods.showMessage(e,c)}})},setMethod:function setMethod(a,b,c,d){c.methods||(c.methods={}),c.methods[b]?console.error(MESSAGES.methodNameConflict+b):c.methods[b]=innerMethods.makeMethod(a,b,c,d)},makeMethod:function makeMethod(a,b,c,d){return function(e){var f={};return Object.assign(f,VueNotifications.config),Object.assign(f,c[VueNotifications.propertyName][b]),Object.assign(f,e),innerMethods.showMessage(f,d,a)}},initVueNotificationPlugin:function initVueNotificationPlugin(a,b,c){b&&(Object.keys(b).forEach(function(d){innerMethods.setMethod(a,d,a.$options,c)}),a.$emit(PACKAGE_NAME+'-initiated'))},launchWatchableNotifications:function launchWatchableNotifications(a,b){b&&(Object.keys(b).forEach(function(c){a[c]&&b[c].watch&&a[c]()}),a.$emit(PACKAGE_NAME+'-launched_watchable'))},unlinkVueNotificationPlugin:function unlinkVueNotificationPlugin(a,b){b&&function(){var c=a.$options.methods;Object.keys(b).forEach(function(d){c[d]&&(c[d]=void 0,delete c[d])}),a.$emit(PACKAGE_NAME+'-unlinked')}()}};function makeMixin(a,b){var _ref5,c={init:'',destroy:'beforeDestroy',mounted:''};return innerMethods.getVersion(a).major===VUE_VERSION.evangelion&&(c.init='init',c.mounted='compiled'),innerMethods.getVersion(a).major===VUE_VERSION.ghostInTheShell&&(c.init='beforeCreate',c.mounted='mounted'),(_ref5={},_defineProperty(_ref5,c.init,function(){var d=this,e=this.$options,f=e[VueNotifications.propertyName];innerMethods.initVueNotificationPlugin(d,f,b)}),_defineProperty(_ref5,c.mounted,function(){var d=this,e=this.$options,f=e[VueNotifications.propertyName];innerMethods.launchWatchableNotifications(d,f)}),_defineProperty(_ref5,c.destroy,function(){var d=this,e=this.$options,f=e[VueNotifications.propertyName];innerMethods.unlinkVueNotificationPlugin(d,f)}),_ref5)}var VueNotifications={type:TYPE,propertyName:PROPERTY_NAME,config:{type:TYPE.info,timeout:3000},installed:!1,install:function install(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(this.installed)throw console.error(MESSAGES.alreadyInstalled);var c=makeMixin(a,b);a.mixin(c),innerMethods.addMethods(this,this.type,b),this.installed=!0}};'undefined'!=typeof window&&window.Vue&&window.Vue.use(VueNotifications);
{
"name": "vue-notifications",
"version": "0.7.5",
"version": "0.7.6",
"description": "Vuejs notifications",

@@ -5,0 +5,0 @@ "main": "dist/vue-notifications.es5.js",

@@ -5,6 +5,6 @@ ### TODOs

| main.js | 141 | @S.Panfilov handle class add and remove here
| main.js | 163 | @S.Panfilov BUG: Weird behaviour: cb calls 2 times
| main.js | 165 | @S.Panfilov bug here
| main.js | 230 | @S.Panfilov fix 'vueApp' in param
| main.js | 171 | @S.Panfilov BUG: Weird behaviour: cb calls 2 times
| main.js | 173 | @S.Panfilov bug here
| main.js | 232 | @S.Panfilov fix 'vueApp' in param
| main.js | 248 | @S.Panfilov not sure - throw error here or just warn
| unit/main.spec.js | 283 | @S.Panfilov fix this test

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