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.6 to 0.8.0

2

build/config.js

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

'use strict'
const SRC = 'src'

@@ -4,0 +2,0 @@ const DEST = 'dist'

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

'use strict'
const gulp = require('gulp')

@@ -4,0 +2,0 @@

7

build/tasks/es6.js

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

'use strict'
const gulp = require('gulp')

@@ -16,3 +14,3 @@

.pipe(plumber({
errorHandler: notify.onError(function (err) {
errorHandler: notify.onError(err => {
return {

@@ -31,6 +29,5 @@ title: 'Build ES6',

.pipe(babel({ presets: ['babili'], comments: false }))
// TODO (S.Panfilov) Remove comments
// TODO (S.Panfilov) Perhaps add sourcemaps
// // TODO (S.Panfilov) Perhaps add sourcemaps
.pipe(rename({ basename: `${config.projectName}.es6.min` }))
.pipe(gulp.dest(config.dest))
})

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

'use strict'
const gulp = require('gulp')

@@ -4,0 +2,0 @@ const runSequence = require('run-sequence').use(gulp)

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

'use strict'
const gulp = require('gulp')

@@ -4,0 +2,0 @@ const size = require('gulp-size')

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

'use strict'
const gulp = require('gulp')

@@ -4,0 +2,0 @@ const config = require('../config')

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

var VUE_VERSION = {
evangelion: 1,
ghostInTheShell: 2
eva: 1,
ghost: 2
};

@@ -36,342 +36,103 @@

var innerMethods = {
/**
* @param {Object} Vue
* @return {Object}
*/
getVersion: function getVersion(Vue) {
var version = Vue.version.match(/(\d+)/g);
return {
major: +version[0],
regular: +version[1],
minor: +version[2]
};
},
function getMajorVersion(Vue) {
var version = Vue.version.match(/(\d+)/g);
return +version[0];
}
function showInConsole(msg, type, types) {
if (type === types.error) console.error(msg);else if (type === types.warn) console.warn(msg);else if (type === types.success) console.info(msg);else console.log(msg);
}
/**
* @param {String} msg
* @param {String} type
* @param {Object} types
*/
showInConsole: function showInConsole(msg, type, types) {
if (type === types.error) console.error(msg);else if (type === types.warn) console.warn(msg);else if (type === types.success) console.info(msg);else console.log(msg);
},
function showDefaultMessage(_ref) {
var type = _ref.type,
message = _ref.message,
title = _ref.title,
debugMsg = _ref.debugMsg;
var msg = 'Title: ' + title + ' Message: ' + message + ' DebugMsg: ' + debugMsg + ' type: ' + type;
/**
* @param {String} type
* @param {String} message
* @param {String} title
* @param {String} debugMsg
* @return {String}
*/
showDefaultMessage: function showDefaultMessage(_ref) {
var type = _ref.type,
message = _ref.message,
title = _ref.title,
debugMsg = _ref.debugMsg;
showInConsole(msg, type, TYPE);
var msg = 'Title: ' + title + ', Message: ' + message + ', DebugMsg: ' + debugMsg + ', type: ' + type;
return msg;
}
function getValues(vueApp, config) {
var result = {};
var keepFnFields = ['cb'];
innerMethods.showInConsole(msg, type, TYPE);
return msg;
},
/**
* @param {Object} elem
* @param {String} className
*/
addClass: function addClass(elem, className) {
if (elem.classList) {
elem.classList.add(className);
} else {
elem.className += ' ' + className;
}
},
/**
* @param {Object} elem
* @param {String} className
*/
removeClass: function removeClass(elem, className) {
if (elem.classList) {
elem.classList.remove(className);
} else {
elem.className = elem.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
},
/**
* @param {Object} elem
* @param {String} className
* @return {Boolean}
*/
hasClass: function hasClass(elem, className) {
if (elem.classList) {
return elem.classList.contains(className);
} else {
return new RegExp('(^| )' + className + '( |$)', 'gi').test(elem.className);
}
},
/**
* @param {Object} elem
* @param {String} message
* @param {String} inClass
* @param {String} outClass
*/
showInlineFn: function showInlineFn(elem, message, _ref2) {
var inClass = _ref2.inClass,
outClass = _ref2.outClass;
elem.innerText = message;
if (inClass) {
if (!innerMethods.hasClass(elem, inClass)) innerMethods.addClass(elem, inClass);
}
if (outClass) {
if (innerMethods.hasClass(elem, outClass)) innerMethods.removeClass(elem, outClass);
}
},
/**
* @param {Object} elem
* @param {String} inClass
* @param {String} outClass
*/
clearInlineFn: function clearInlineFn(elem, _ref3) {
var inClass = _ref3.inClass,
outClass = _ref3.outClass;
if (inClass) {
if (innerMethods.hasClass(elem, inClass)) innerMethods.removeClass(elem, inClass);
}
if (outClass) {
if (!innerMethods.hasClass(elem, outClass)) innerMethods.addClass(elem, outClass);
}
elem.innerText = '';
},
/**
* @param {String} id
* @param {String} type
* @param {String} timeout
* @param {String} message
* @param {Object} classes
* @param {Function} watch
* @param {String} debugMsg
* @param {Function} cb
* @param {Object} vueApp
* @return {String}
*/
showInlineMessage: function showInlineMessage(_ref4, vueApp) {
var id = _ref4.id,
type = _ref4.type,
timeout = _ref4.timeout,
message = _ref4.message,
_ref4$classes = _ref4.classes,
classes = _ref4$classes === undefined ? {} : _ref4$classes,
watch = _ref4.watch,
debugMsg = _ref4.debugMsg,
cb = _ref4.cb;
// TODO (S.Panfilov) handle class add and remove here
if (debugMsg) innerMethods.showInConsole(debugMsg, type, TYPE);
var elem = document.getElementById(id);
if (watch) {
(function () {
timeout = false;
if (watch && watch()) innerMethods.showInlineFn(elem, message, 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;
}
}
}, 50);
})();
}
if (!watch) {
innerMethods.showInlineFn(elem, message, classes);
setTimeout(function () {
innerMethods.clearInlineFn.call(vueApp, elem, classes);
}, timeout);
}
// TODO (S.Panfilov) BUG: Weird behaviour: cb calls 2 times
if (cb) {
// TODO (S.Panfilov) bug here
cb.call(vueApp, elem, function () {
return innerMethods.clearInlineFn.call(innerMethods, elem, classes);
});
}
return message;
},
/**
* @param {Object} vueApp
* @param {Object} config
* @return {Object}
*/
getValues: function getValues(vueApp, config) {
var result = {};
var keepFnFields = ['cb', 'watch'];
Object.keys(config).forEach(function (field) {
keepFnFields.forEach(function (fnField) {
if (field === fnField) {
result[field] = config[field].bind(vueApp);
} else {
result[field] = typeof config[field] === 'function' ? config[field].call(vueApp) : config[field];
}
});
Object.keys(config).forEach(function (field) {
keepFnFields.forEach(function (fnField) {
if (field === fnField) {
result[field] = config[field].bind(vueApp);
} else {
result[field] = typeof config[field] === 'function' ? config[field].call(vueApp) : config[field];
}
});
});
return result;
},
return result;
}
function showMessage(config, options, vueApp) {
var valuesObj = getValues(vueApp, config);
var isMethodOverridden = options && options[valuesObj.type];
var method = isMethodOverridden ? options[valuesObj.type] : showDefaultMessage;
method(valuesObj, vueApp);
/**
* @param {Object} config
* @param {Object} options
* @param {Object} vueApp
*/
showMessage: function showMessage(config, options, vueApp) {
var valuesObj = innerMethods.getValues(vueApp, config);
var isLinkedToElem = !!valuesObj.id;
if (config.cb) return config.cb();
}
if (isLinkedToElem) {
innerMethods.showInlineMessage(valuesObj, vueApp);
} else {
var isMethodOverridden = options && options[valuesObj.type];
var method = isMethodOverridden ? options[valuesObj.type] : innerMethods.showDefaultMessage;
method(valuesObj, vueApp);
}
function addMethods(targetObj, typesObj, options) {
Object.keys(typesObj).forEach(function (v) {
targetObj[typesObj[v]] = function (config) {
config.type = typesObj[v];
// TODO (S.Panfilov)fix 'vueApp' in param
return showMessage(config, options);
};
});
}
if (config.cb) return config.cb();
},
function setMethod(vueApp, name, options, pluginOptions) {
if (!options.methods) options.methods = {};
if (options.methods[name]) {
// TODO (S.Panfilov) not sure - throw error here or just warn
console.error(MESSAGES.methodNameConflict + name);
} else {
options.methods[name] = makeMethod(vueApp, name, options, pluginOptions);
}
}
/**
* @param {Object} targetObj
* @param {Object} typesObj
* @param {Object} options
* @return {undefined}
* */
addMethods: function addMethods(targetObj, typesObj, options) {
Object.keys(typesObj).forEach(function (v) {
targetObj[typesObj[v]] = function (config) {
config.type = typesObj[v];
// TODO (S.Panfilov)fix 'vueApp' in param
return innerMethods.showMessage(config, options);
};
});
},
function makeMethod(vueApp, configName, options, pluginOptions) {
return function (config) {
var newConfig = {};
Object.assign(newConfig, VueNotifications.config);
Object.assign(newConfig, options[VueNotifications.propertyName][configName]);
Object.assign(newConfig, config);
return showMessage(newConfig, pluginOptions, vueApp);
};
}
function initVueNotificationPlugin(vueApp, notifications, pluginOptions) {
if (!notifications) return;
Object.keys(notifications).forEach(function (name) {
setMethod(vueApp, name, vueApp.$options, pluginOptions);
});
/**
* @param {Object} vueApp
* @param {String} name
* @param {Object} options
* @param {Object} pluginOptions
*/
setMethod: function setMethod(vueApp, name, options, pluginOptions) {
if (!options.methods) options.methods = {};
if (options.methods[name]) {
// TODO (S.Panfilov) not sure - throw error here or just warn
console.error(MESSAGES.methodNameConflict + name);
} else {
options.methods[name] = innerMethods.makeMethod(vueApp, name, options, pluginOptions);
vueApp.$emit(PACKAGE_NAME + '-initiated');
}
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 {Object} vueApp
* @param {String} configName
* @param {Object} options
* @param {Object} pluginOptions
* @return {Function}
*/
makeMethod: function makeMethod(vueApp, configName, options, pluginOptions) {
return function (config) {
var newConfig = {};
Object.assign(newConfig, VueNotifications.config);
Object.assign(newConfig, options[VueNotifications.propertyName][configName]);
Object.assign(newConfig, config);
return innerMethods.showMessage(newConfig, pluginOptions, vueApp);
};
},
/**
* @param {Object} vueApp
* @param {Object} notifications
* @param {Object} pluginOptions
*/
initVueNotificationPlugin: function initVueNotificationPlugin(vueApp, notifications, pluginOptions) {
if (!notifications) return;
Object.keys(notifications).forEach(function (name) {
innerMethods.setMethod(vueApp, name, vueApp.$options, pluginOptions);
});
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 _ref2;

@@ -384,7 +145,7 @@ var hooks = {

if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) {
if (getMajorVersion(Vue) === VUE_VERSION.eva) {
hooks.init = 'init';
hooks.mounted = 'compiled';
}
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) {
if (getMajorVersion(Vue) === VUE_VERSION.ghost) {
hooks.init = 'beforeCreate';

@@ -394,3 +155,3 @@ hooks.mounted = 'mounted';

return _ref5 = {}, _defineProperty(_ref5, hooks.init, function () {
return _ref2 = {}, _defineProperty(_ref2, hooks.init, function () {
var vueApp = this;

@@ -400,15 +161,9 @@ var vueAppOptions = this.$options;

innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions);
}), _defineProperty(_ref5, hooks.mounted, function () {
initVueNotificationPlugin(vueApp, notificationsField, pluginOptions);
}), _defineProperty(_ref2, hooks.destroy, 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;
unlinkVueNotificationPlugin(vueApp, notificationsField);
}), _ref2;
}

@@ -437,6 +192,10 @@

innerMethods.addMethods(this, this.type, pluginOptions);
addMethods(this, this.type, pluginOptions);
this.installed = true;
}
//TODO (S.Panfilov) add ability to access this.notifications.someError.message
//TODO (S.Panfilov) add "noCall:true" property
};

@@ -443,0 +202,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";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});
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.VueNotifications=t()}(this,function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e){return+e.version.match(/(\d+)/g)[0]}function n(e,t,n){t===n.error?console.error(e):t===n.warn?console.warn(e):t===n.success?console.info(e):console.log(e)}function o(e){var t=e.type,o=e.message,i=e.title,r=e.debugMsg,s="Title: "+i+" Message: "+o+" DebugMsg: "+r+" type: "+t;return n(s,t,p),s}function i(e,t){var n={},o=["cb"];return Object.keys(t).forEach(function(i){o.forEach(function(o){n[i]=i===o?t[i].bind(e):"function"==typeof t[i]?t[i].call(e):t[i]})}),n}function r(e,t,n){var r=i(n,e);if((t&&t[r.type]?t[r.type]:o)(r,n),e.cb)return e.cb()}function s(e,t,n){Object.keys(t).forEach(function(o){e[t[o]]=function(e){return e.type=t[o],r(e,n)}})}function c(e,t,n,o){n.methods||(n.methods={}),n.methods[t]?console.error(y.methodNameConflict+t):n.methods[t]=u(e,t,n,o)}function u(e,t,n,o){return function(i){var s={};return Object.assign(s,h.config),Object.assign(s,n[h.propertyName][t]),Object.assign(s,i),r(s,o,e)}}function f(e,t,n){t&&(Object.keys(t).forEach(function(t){c(e,t,e.$options,n)}),e.$emit(l+"-initiated"))}function a(e,t){if(t){var n=e.$options.methods;Object.keys(t).forEach(function(e){n[e]&&(n[e]=void 0,delete n[e])}),e.$emit(l+"-unlinked")}}function d(n,o){var i,r={init:"",destroy:"beforeDestroy",mounted:""};return t(n)===m.eva&&(r.init="init",r.mounted="compiled"),t(n)===m.ghost&&(r.init="beforeCreate",r.mounted="mounted"),i={},e(i,r.init,function(){f(this,this.$options[h.propertyName],o)}),e(i,r.destroy,function(){a(this,this.$options[h.propertyName])}),i}var l="vue-notifications",p={error:"error",warn:"warn",info:"info",success:"success"},m={eva:1,ghost:2},y={alreadyInstalled:"VueNotifications: plugin already installed",methodNameConflict:"VueNotifications: names conflict - "},h={type:p,propertyName:"notifications",config:{type:p.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(y.alreadyInstalled);var n=d(e,t);e.mixin(n),s(this,this.type,t),this.installed=!0}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(h),h});
//# sourceMappingURL=vue-notifications.es5.min.js.map

@@ -13,4 +13,4 @@ const PLUGIN_NAME = 'VueNotifications'

const VUE_VERSION = {
evangelion: 1,
ghostInTheShell: 2
eva: 1,
ghost: 2
}

@@ -23,302 +23,99 @@

const innerMethods = {
/**
* @param {Object} Vue
* @return {Object}
*/
getVersion (Vue) {
const version = Vue.version.match(/(\d+)/g)
return {
major: +version[0],
regular: +version[1],
minor: +version[2]
}
},
function getMajorVersion (Vue) {
const version = Vue.version.match(/(\d+)/g)
return +version[0]
}
/**
* @param {String} msg
* @param {String} type
* @param {Object} types
*/
showInConsole (msg, type, types) {
if (type === types.error) console.error(msg)
else if (type === types.warn) console.warn(msg)
else if (type === types.success) console.info(msg)
else console.log(msg)
},
function showInConsole (msg, type, types) {
if (type === types.error) console.error(msg)
else if (type === types.warn) console.warn(msg)
else if (type === types.success) console.info(msg)
else console.log(msg)
}
/**
* @param {String} type
* @param {String} message
* @param {String} title
* @param {String} debugMsg
* @return {String}
*/
showDefaultMessage ({ type, message, title, debugMsg }) {
let msg = `Title: ${title}, Message: ${message}, DebugMsg: ${debugMsg}, type: ${type}`
function showDefaultMessage ({type, message, title, debugMsg}) {
let msg = `Title: ${title} Message: ${message} DebugMsg: ${debugMsg} type: ${type}`
innerMethods.showInConsole(msg, type, TYPE)
showInConsole(msg, type, TYPE)
return msg
},
/**
* @param {Object} elem
* @param {String} className
*/
addClass (elem, className) {
if (elem.classList) {
elem.classList.add(className)
} else {
elem.className += ' ' + className
}
},
/**
* @param {Object} elem
* @param {String} className
*/
removeClass (elem, className) {
if (elem.classList) {
elem.classList.remove(className)
} else {
elem.className = elem.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ')
}
},
/**
* @param {Object} elem
* @param {String} className
* @return {Boolean}
*/
hasClass (elem, className) {
if (elem.classList) {
return elem.classList.contains(className)
} else {
return new RegExp('(^| )' + className + '( |$)', 'gi').test(elem.className)
}
},
/**
* @param {Object} elem
* @param {String} message
* @param {String} inClass
* @param {String} outClass
*/
showInlineFn (elem, message, { inClass, outClass }) {
elem.innerText = message
if (inClass) {
if (!innerMethods.hasClass(elem, inClass)) innerMethods.addClass(elem, inClass)
}
return msg
}
function getValues (vueApp, config) {
const result = {}
const keepFnFields = ['cb']
if (outClass) {
if (innerMethods.hasClass(elem, outClass)) innerMethods.removeClass(elem, outClass)
}
},
/**
* @param {Object} elem
* @param {String} inClass
* @param {String} outClass
*/
clearInlineFn (elem, { inClass, outClass }) {
if (inClass) {
if (innerMethods.hasClass(elem, inClass)) innerMethods.removeClass(elem, inClass)
}
Object.keys(config).forEach(field => {
keepFnFields.forEach(fnField => {
if (field === fnField) {
result[field] = config[field].bind(vueApp)
} else {
result[field] = (typeof config[field] === 'function') ? config[field].call(vueApp) : config[field]
}
})
})
if (outClass) {
if (!innerMethods.hasClass(elem, outClass)) innerMethods.addClass(elem, outClass)
}
return result
}
elem.innerText = ''
},
/**
* @param {String} id
* @param {String} type
* @param {String} timeout
* @param {String} message
* @param {Object} classes
* @param {Function} watch
* @param {String} debugMsg
* @param {Function} cb
* @param {Object} vueApp
* @return {String}
*/
showInlineMessage ({ id, type, timeout, message, classes = {}, watch, debugMsg, cb }, vueApp) {
// TODO (S.Panfilov) handle class add and remove here
if (debugMsg) innerMethods.showInConsole(debugMsg, type, TYPE)
const elem = document.getElementById(id)
function showMessage (config, options, vueApp) {
const valuesObj = getValues(vueApp, config)
const isMethodOverridden = options && options[valuesObj.type]
const method = isMethodOverridden ? options[valuesObj.type] : showDefaultMessage
method(valuesObj, vueApp)
if (watch) {
timeout = false
if (watch && watch()) innerMethods.showInlineFn(elem, message, 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
}
}
}, 50)
}
if (config.cb) return config.cb()
}
if (!watch) {
innerMethods.showInlineFn(elem, message, classes)
setTimeout(() => {
innerMethods.clearInlineFn.call(vueApp, elem, classes)
}, timeout)
function addMethods (targetObj, typesObj, options) {
Object.keys(typesObj).forEach(v => {
targetObj[typesObj[v]] = function (config) {
config.type = typesObj[v]
// TODO (S.Panfilov)fix 'vueApp' in param
return showMessage(config, options)
}
})
}
// TODO (S.Panfilov) BUG: Weird behaviour: cb calls 2 times
if (cb) {
// TODO (S.Panfilov) bug here
cb.call(vueApp, elem, () => innerMethods.clearInlineFn.call(innerMethods, elem, classes))
}
function setMethod (vueApp, name, options, pluginOptions) {
if (!options.methods) options.methods = {}
return message
},
if (options.methods[name]) {
// TODO (S.Panfilov) not sure - throw error here or just warn
console.error(MESSAGES.methodNameConflict + name)
} else {
options.methods[name] = makeMethod(vueApp, name, options, pluginOptions)
}
}
/**
* @param {Object} vueApp
* @param {Object} config
* @return {Object}
*/
getValues (vueApp, config) {
const result = {}
const keepFnFields = ['cb', 'watch']
function makeMethod (vueApp, configName, options, pluginOptions) {
return function (config) {
const newConfig = {}
Object.assign(newConfig, VueNotifications.config)
Object.assign(newConfig, options[VueNotifications.propertyName][configName])
Object.assign(newConfig, config)
Object.keys(config).forEach(field => {
keepFnFields.forEach(fnField => {
if (field === fnField) {
result[field] = config[field].bind(vueApp)
} else {
result[field] = (typeof config[field] === 'function') ? config[field].call(vueApp) : config[field]
}
})
})
return showMessage(newConfig, pluginOptions, vueApp)
}
}
function initVueNotificationPlugin (vueApp, notifications, pluginOptions) {
if (!notifications) return
Object.keys(notifications).forEach(name => {
setMethod(vueApp, name, vueApp.$options, pluginOptions)
})
return result
},
/**
* @param {Object} config
* @param {Object} options
* @param {Object} vueApp
*/
showMessage (config, options, vueApp) {
const valuesObj = innerMethods.getValues(vueApp, config)
const isLinkedToElem = !!valuesObj.id
if (isLinkedToElem) {
innerMethods.showInlineMessage(valuesObj, vueApp)
} else {
const isMethodOverridden = options && options[valuesObj.type]
const method = isMethodOverridden ? options[valuesObj.type] : innerMethods.showDefaultMessage
method(valuesObj, vueApp)
vueApp.$emit(`${PACKAGE_NAME}-initiated`)
}
function 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]
}
})
if (config.cb) return config.cb()
},
/**
* @param {Object} targetObj
* @param {Object} typesObj
* @param {Object} options
* @return {undefined}
* */
addMethods (targetObj, typesObj, options) {
Object.keys(typesObj).forEach(v => {
targetObj[typesObj[v]] = function (config) {
config.type = typesObj[v]
// TODO (S.Panfilov)fix 'vueApp' in param
return innerMethods.showMessage(config, options)
}
})
},
/**
* @param {Object} vueApp
* @param {String} name
* @param {Object} options
* @param {Object} pluginOptions
*/
setMethod (vueApp, name, options, pluginOptions) {
if (!options.methods) options.methods = {}
if (options.methods[name]) {
// TODO (S.Panfilov) not sure - throw error here or just warn
console.error(MESSAGES.methodNameConflict + name)
} else {
options.methods[name] = innerMethods.makeMethod(vueApp, name, options, pluginOptions)
}
},
/**
* @param {Object} vueApp
* @param {String} configName
* @param {Object} options
* @param {Object} pluginOptions
* @return {Function}
*/
makeMethod (vueApp, configName, options, pluginOptions) {
return function (config) {
const newConfig = {}
Object.assign(newConfig, VueNotifications.config)
Object.assign(newConfig, options[VueNotifications.propertyName][configName])
Object.assign(newConfig, config)
return innerMethods.showMessage(newConfig, pluginOptions, vueApp)
}
},
/**
* @param {Object} vueApp
* @param {Object} notifications
* @param {Object} pluginOptions
*/
initVueNotificationPlugin (vueApp, notifications, pluginOptions) {
if (!notifications) return
Object.keys(notifications).forEach(name => {
innerMethods.setMethod(vueApp, name, vueApp.$options, pluginOptions)
})
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`)
}
vueApp.$emit(`${PACKAGE_NAME}-unlinked`)
}
/**
* @param {Function} Vue
* @param {Object} pluginOptions
* @return {Object}
*/
function makeMixin (Vue, pluginOptions) {

@@ -331,7 +128,7 @@ let hooks = {

if (innerMethods.getVersion(Vue).major === VUE_VERSION.evangelion) {
if (getMajorVersion(Vue) === VUE_VERSION.eva) {
hooks.init = 'init'
hooks.mounted = 'compiled'
}
if (innerMethods.getVersion(Vue).major === VUE_VERSION.ghostInTheShell) {
if (getMajorVersion(Vue) === VUE_VERSION.ghost) {
hooks.init = 'beforeCreate'

@@ -347,11 +144,4 @@ hooks.mounted = 'mounted'

innerMethods.initVueNotificationPlugin(vueApp, notificationsField, pluginOptions)
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 () {

@@ -361,3 +151,3 @@ const vueApp = this

const notificationsField = vueAppOptions[VueNotifications.propertyName]
innerMethods.unlinkVueNotificationPlugin(vueApp, notificationsField)
unlinkVueNotificationPlugin(vueApp, notificationsField)
}

@@ -386,6 +176,9 @@ }

innerMethods.addMethods(this, this.type, pluginOptions)
addMethods(this, this.type, pluginOptions)
this.installed = true
}
//TODO (S.Panfilov) add ability to access this.notifications.someError.message
//TODO (S.Panfilov) add "noCall:true" property
}

@@ -392,0 +185,0 @@

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

'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);
'use strict';function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var PLUGIN_NAME='VueNotifications',PACKAGE_NAME='vue-notifications',PROPERTY_NAME='notifications',TYPE={error:'error',warn:'warn',info:'info',success:'success'},VUE_VERSION={eva:1,ghost:2},MESSAGES={alreadyInstalled:PLUGIN_NAME+': plugin already installed',methodNameConflict:PLUGIN_NAME+': names conflict - '};function getMajorVersion(a){var b=a.version.match(/(\d+)/g);return+b[0]}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)}function showDefaultMessage(a){var b=a.type,c=a.message,d=a.title,e=a.debugMsg,f='Title: '+d+' Message: '+c+' DebugMsg: '+e+' type: '+b;return showInConsole(f,b,TYPE),f}function getValues(a,b){var c={},d=['cb'];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}function showMessage(a,b,c){var d=getValues(c,a),e=b&&b[d.type],f=e?b[d.type]:showDefaultMessage;if(f(d,c),a.cb)return a.cb()}function addMethods(a,b,c){Object.keys(b).forEach(function(d){a[b[d]]=function(e){return e.type=b[d],showMessage(e,c)}})}function setMethod(a,b,c,d){c.methods||(c.methods={}),c.methods[b]?console.error(MESSAGES.methodNameConflict+b):c.methods[b]=makeMethod(a,b,c,d)}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),showMessage(f,d,a)}}function initVueNotificationPlugin(a,b,c){b&&(Object.keys(b).forEach(function(d){setMethod(a,d,a.$options,c)}),a.$emit(PACKAGE_NAME+'-initiated'))}function unlinkVueNotificationPlugin(a,b){if(b){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 c,d={init:'',destroy:'beforeDestroy',mounted:''};return getMajorVersion(a)===VUE_VERSION.eva&&(d.init='init',d.mounted='compiled'),getMajorVersion(a)===VUE_VERSION.ghost&&(d.init='beforeCreate',d.mounted='mounted'),(c={},_defineProperty(c,d.init,function(){var e=this,f=this.$options,g=f[VueNotifications.propertyName];initVueNotificationPlugin(e,g,b)}),_defineProperty(c,d.destroy,function(){var e=this,f=this.$options,g=f[VueNotifications.propertyName];unlinkVueNotificationPlugin(e,g)}),c)}var VueNotifications={type:TYPE,propertyName:PROPERTY_NAME,config:{type:TYPE.info,timeout:3e3},installed:!1,install:function install(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};if(this.installed)throw console.error(MESSAGES.alreadyInstalled);var c=makeMixin(a,b);a.mixin(c),addMethods(this,this.type,b),this.installed=!0}};'undefined'!=typeof window&&window.Vue&&window.Vue.use(VueNotifications);
{
"name": "vue-notifications",
"version": "0.7.6",
"version": "0.8.0",
"description": "Vuejs notifications",

@@ -9,6 +9,6 @@ "main": "dist/vue-notifications.es5.js",

"build": "gulp make",
"update": "ncu -a && npm update",
"upgrade": "npm upgrade",
"update": "ncu -a && yarn upgrade",
"upgrade": "yarn upgrade",
"test": "mocha --compilers js:babel-core/register ./test/**/*.spec.js",
"lint": "eslint ./src"
"lint": "./node_modules/eslint/bin/eslint.js ./src"
},

@@ -38,43 +38,45 @@ "repository": {

"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.16.0",
"babel-core": "^6.18.0",
"babel-loader": "^6.2.5",
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
"babel-plugin-transform-es3-property-literals": "^6.8.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-latest": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-runtime": "^6.18.0",
"babel": "^6.23.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.23.0",
"babelify": "^7.3.0",
"babili": "0.0.8",
"browserify": "^13.1.1",
"babili": "0.0.12",
"browserify": "^14.3.0",
"chai": "^3.5.0",
"eslint": "^3.10.1",
"eslint-config-standard": "^6.2.1",
"eslint-friendly-formatter": "^2.0.6",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-standard": "^2.0.1",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.0",
"eslint-friendly-formatter": "^2.0.7",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-concat": "^2.6.1",
"gulp-eslint": "^3.0.1",
"gulp-notify": "^2.2.0",
"gulp-notify": "^3.0.0",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-size": "^2.1.0",
"gulp-sourcemaps": "^2.2.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-strip-code": "^0.1.4",
"gulp-todo": "^5.1.0",
"gulp-uglify": "^2.0.0",
"gulp-umd": "^0.2.0",
"gulp-watch": "^4.3.10",
"mocha": "^3.1.2",
"require-dir": "^0.3.0",
"gulp-todo": "^5.3.0",
"gulp-uglify": "^2.1.2",
"gulp-umd": "^0.2.1",
"gulp-watch": "^4.3.11",
"mocha": "^3.2.0",
"require-dir": "^0.3.1",
"run-sequence": "^1.2.2",
"sinon": "^1.17.6",
"sinon-chai": "^2.8.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"source": "0.0.3",
"through2": "^2.0.1",
"through2": "^2.0.3",
"to-case": "^2.0.0",

@@ -81,0 +83,0 @@ "vinyl-buffer": "^1.0.0",

@@ -16,3 +16,3 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a6dee4e21d04653b53c0a9618a2cc84)](https://www.codacy.com/app/se-panfilov/vue-notifications?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=se-panfilov/vue-notifications&amp;utm_campaign=Badge_Grade)

##Instalation
## Installation

@@ -27,3 +27,3 @@ via npm:

```shell
```sh
bower i vue-notifications --save

@@ -43,3 +43,3 @@ ```

##Setup and configuration
## Setup and configuration

@@ -49,8 +49,19 @@ **Attention:** By default VueNotification send all messages _to console_. To activate non-blocking notifiction you've got to use third-party library, like toasr. I suggest you to use [mini-toastr][2] (`npm i mini-toastr --save`)

```JS
//Include Plugin in project
// Include Plugin in project
import VueNotifications from 'vue-notifications'
//Include mini-toaster (or any other UI-notification library
// Include mini-toaster (or any other UI-notification library
import miniToastr from 'mini-toastr'
//Here we setup messages output to `mini-toastr`
// If using mini-toastr, provide additional configuration
const toastTypes = {
success: 'success',
error: 'error',
info: 'info',
warn: 'warn'
}
miniToastr.init({types: toastTypes})
// Here we setup messages output to `mini-toastr`
function toast ({title, message, type, timeout, cb}) {

@@ -60,5 +71,5 @@ return miniToastr[type](message, title, timeout, cb)

//Binding for methods .success(), .error() and etc. You can specify and map your own methods here.
//Required to pipe our outout to UI library (mini-toastr in example here)
//All not-specifyed events (types) would be piped to output in console.
// Binding for methods .success(), .error() and etc. You can specify and map your own methods here.
// Required to pipe our output to UI library (mini-toastr in example here)
// All not-specified events (types) would be piped to output in console.
const options = {

@@ -71,3 +82,3 @@ success: toast,

//Activate plugin
// Activate plugin
Vue.use(VueNotifications, options)// VueNotifications have auto install but if we want to specify options we've got to do it manually.

@@ -77,4 +88,4 @@ ```

```JS
//THIS ISN'T REQUIRED IF YOU DON'T USE 'mini-toastr'
//and if you would use "miniToastr" you have to init in in your App.vue
// THIS ISN'T REQUIRED IF YOU DON'T USE 'mini-toastr'
// and if you would use "miniToastr" you have to init in in your App.vue
import miniToastr from 'mini-toastr'// don't forget to make "npm i mini-toastr --save"

@@ -104,3 +115,3 @@

##Usage
## Usage

@@ -143,3 +154,3 @@ You've got to specify notifications config:

```
####Overriding config.
#### Overriding config.

@@ -163,3 +174,3 @@ Even if you have specify config, you can ovverride it in any call simple by sending config object: `this.showLoginError({type: 'warn'})`. i.e.:

##Options
## Options

@@ -175,3 +186,3 @@ **VueNotification** can work fine with any of your custom options, but by default it would be:

####How to add custom field?
#### How to add custom field?

@@ -214,15 +225,11 @@ Simple: `this.showLoginError({consoleMessage: 'let it be in console'})`. You've passed a custom config here (`{consoleMessage: 'let it be in console'}`) that will be merged with config from `notifications.showLoginError` and with `global config` via `Object.assign` (beware of shallow copy).

##Browser support.
## Browser support.
All modern browsers (`ES5` support require). See [ECMAScript 5 compliant browsers][3].
You can use `ES5` or `ES6` versions as well.
###ROADMAP:
## License
1. Add native support for `computed` properties.
##License
MIT License
Copyright (c) 2016 Sergey Panfilov
Copyright (c) 2016 Sergei Panfilov

@@ -229,0 +236,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -37,3 +37,3 @@ 'use strict'

it('getVersion.', () => {
it('getMajorVersion.', () => {

@@ -44,7 +44,5 @@ const vue = {

const result = _private.getVersion(vue)
expect(result).to.be.a('object')
expect(result.major).to.be.equal(1)
expect(result.regular).to.be.equal(0)
expect(result.minor).to.be.equal(12)
const result = _private.getMajorVersion(vue)
expect(result).to.be.a('number')
expect(result).to.be.equal(1)
})

@@ -78,3 +76,3 @@

const expectedMsg = `Title: ${config.title}, Message: ${config.message}, DebugMsg: ${config.debugMsg}, type: ${config.type}`
const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)

@@ -92,3 +90,3 @@ expect(result).to.be.equal(expectedMsg)

const expectedMsg = `Title: ${config.title}, Message: ${config.message}, DebugMsg: ${config.debugMsg}, type: ${config.type}`
const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)

@@ -106,3 +104,3 @@ expect(result).to.be.equal(expectedMsg)

const expectedMsg = `Title: ${config.title}, Message: ${config.message}, DebugMsg: ${config.debugMsg}, type: ${config.type}`
const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)

@@ -120,3 +118,3 @@ expect(result).to.be.equal(expectedMsg)

const expectedMsg = `Title: ${config.title}, Message: ${config.message}, DebugMsg: ${config.debugMsg}, type: ${config.type}`
const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)

@@ -134,3 +132,3 @@ expect(result).to.be.equal(expectedMsg)

const expectedMsg = `Title: ${config.title}, Message: ${config.message}, DebugMsg: ${config.debugMsg}, type: ${config.type}`
const expectedMsg = `Title: ${config.title} Message: ${config.message} DebugMsg: ${config.debugMsg} type: ${config.type}`
const result = _private.showDefaultMessage(config)

@@ -233,4 +231,3 @@ expect(result).to.be.equal(expectedMsg)

const options = {
methods: {
}
methods: {}
}

@@ -243,4 +240,3 @@ const pluginOptions = {}

const vueApp = {
}
const vueApp = {}

@@ -286,4 +282,3 @@ _private.setMethod(name, options, pluginOptions)

const vueApp = {
}
const vueApp = {}

@@ -290,0 +285,0 @@ const result = _private.makeMethod(vueApp, configName, options, pluginOptions)

### TODOs
| Filename | line # | TODO
|:------|:------:|:------
| main.js | 141 | @S.Panfilov handle class add and remove here
| 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
| main.js | 71 | @S.Panfilov fix 'vueApp' in param
| main.js | 81 | @S.Panfilov not sure - throw error here or just warn
| main.js | 176 | @S.Panfilov add ability to access this.notifications.someError.message
| main.js | 177 | @S.Panfilov add "noCall:true" property
| unit/main.spec.js | 278 | @S.Panfilov fix this test

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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