Socket
Socket
Sign inDemoInstall

notie

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notie - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

src/notie.js

1325

dist/notie.js

@@ -13,824 +13,731 @@ /*

Version: 3.2.0
Version: 3.3.0
*/
var notie = function() {
var notie = (function () {
// Default options
var options = {
colorSuccess: '',
colorWarning: '',
colorError: '',
colorInfo: '',
colorNeutral: '',
colorText: '',
animationDelay: 300,
backgroundClickDismiss: true
}
function setOptions(customOptions) {
// Custom options
for (var key in customOptions) {
options[key] = customOptions[key];
}
}
var options = {
colorSuccess: '',
colorWarning: '',
colorError: '',
colorInfo: '',
colorNeutral: '',
colorText: '',
animationDelay: 300,
backgroundClickDismiss: true
}
function setOptions (customOptions) {
// Custom options
for (var key in customOptions) {
options[key] = customOptions[key]
}
}
// alert
// **************
// **************
// create alert container
var alertOuter = document.createElement('div');
alertOuter.id = 'notie-alert-outer';
var alertOuter = document.createElement('div')
alertOuter.id = 'notie-alert-outer'
// Hide alert on click
alertOuter.onclick = function() {
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
alertHide();
};
// add alert to body
document.body.appendChild(alertOuter);
alertOuter.onclick = function () {
alertHide()
}
// add alert to body
document.body.appendChild(alertOuter)
// create alert inner container
var alertInner = document.createElement('div');
alertInner.id = 'notie-alert-inner';
alertOuter.appendChild(alertInner);
var alertInner = document.createElement('div')
alertInner.id = 'notie-alert-inner'
alertOuter.appendChild(alertInner)
// create alert content container
var alertContent = document.createElement('div');
alertContent.id = 'notie-alert-content';
alertInner.appendChild(alertContent);
// Initialize alert text
var alertText = document.createElement('span');
alertText.id = 'notie-alert-text';
alertContent.appendChild(alertText);
// alert helper variables
var alertIsShowing = false;
var alertTimeout1;
var alertTimeout2;
var wasClickedCounter = 0;
function alert(type, message, seconds) {
if (options.colorText.length > 0) alertText.style.color = options.colorText;
blur();
var alertContent = document.createElement('div')
alertContent.id = 'notie-alert-content'
alertInner.appendChild(alertContent)
wasClickedCounter++;
// Initialize alert text
var alertText = document.createElement('span')
alertText.id = 'notie-alert-text'
alertContent.appendChild(alertText)
setTimeout(function() {
wasClickedCounter--;
}, (options.animationDelay + 10));
// alert helper variables
var alertIsShowing = false
var alertTimeout1
var alertTimeout2
var wasClickedCounter = 0
if (wasClickedCounter === 1) {
function alert (type, message, seconds) {
if (options.colorText.length > 0) alertText.style.color = options.colorText
if (alertIsShowing) {
blur()
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
wasClickedCounter++
alertHide(function() {
alertShow(type, message, seconds);
});
setTimeout(function () {
wasClickedCounter--
}, (options.animationDelay + 10))
}
else {
alertShow(type, message, seconds);
}
if (wasClickedCounter >= 1) {
if (alertIsShowing) {
alertHide(function () {
alertShow(type, message, seconds)
})
} else {
alertShow(type, message, seconds)
}
}
}
}
function alertShow (type, message, seconds) {
alertIsShowing = true
var duration = 0
if (typeof seconds === 'undefined' || seconds === 0) {
duration = 86400000
} else if (seconds > 0 && seconds < 1) {
duration = 1000
} else {
duration = seconds * 1000
}
function alertShow(type, message, seconds) {
// Remove all color classes first
removeClass(alertOuter, 'notie-background-success')
removeClass(alertOuter, 'notie-background-warning')
removeClass(alertOuter, 'notie-background-error')
removeClass(alertOuter, 'notie-background-info')
alertIsShowing = true;
// Set notie type (background color)
switch (type) {
case 1:
case 'success':
if (options.colorSuccess.length > 0) alertOuter.style.backgroundColor = options.colorSuccess
else addClass(alertOuter, 'notie-background-success')
break
case 2:
case 'warning':
if (options.colorWarning.length > 0) alertOuter.style.backgroundColor = options.colorWarning
else addClass(alertOuter, 'notie-background-warning')
break
case 3:
case 'error':
if (options.colorError.length > 0) alertOuter.style.backgroundColor = options.colorError
else addClass(alertOuter, 'notie-background-error')
break
case 4:
case 'info':
if (options.colorInfo.length > 0) alertOuter.style.backgroundColor = options.colorInfo
else addClass(alertOuter, 'notie-background-info')
break
}
var duration = 0;
if (typeof seconds === 'undefined' || seconds === 0) {
var duration = 86400000;
}
else if (seconds > 0 && seconds < 1) {
duration = 1000;
}
else {
duration = seconds * 1000;
}
// Remove all color classes first
removeClass(alertOuter, 'notie-background-success');
removeClass(alertOuter, 'notie-background-warning');
removeClass(alertOuter, 'notie-background-error');
removeClass(alertOuter, 'notie-background-info');
// Set notie type (background color)
switch(type) {
case 1:
if (options.colorSuccess.length > 0) alertOuter.style.backgroundColor = options.colorSuccess;
else addClass(alertOuter, 'notie-background-success');
break;
case 2:
if (options.colorWarning.length > 0) alertOuter.style.backgroundColor = options.colorWarning;
else addClass(alertOuter, 'notie-background-warning');
break;
case 3:
if (options.colorError.length > 0) alertOuter.style.backgroundColor = options.colorError;
else addClass(alertOuter, 'notie-background-error');
break;
case 4:
if (options.colorInfo.length > 0) alertOuter.style.backgroundColor = options.colorInfo;
else addClass(alertOuter, 'notie-background-info');
break;
}
// Set notie text
alertText.innerHTML = message
// Set notie text
alertText.innerHTML = message;
alertOuter.style.top = '-10000px'
alertOuter.style.display = 'table'
alertOuter.style.top = '-' + alertOuter.offsetHeight - 5 + 'px'
alertOuter.style.top = '-10000px';
alertOuter.style.display = 'table';
alertOuter.style.top = '-' + alertOuter.offsetHeight - 5 + 'px';
alertTimeout1 = setTimeout(function () {
addClass(alertOuter, 'notie-transition')
alertTimeout1 = setTimeout(function() {
addClass(alertOuter, 'notie-transition');
alertOuter.style.top = 0
alertOuter.style.top = 0;
alertTimeout2 = setTimeout(function () {
alertHide(function () {
// Nothing
})
}, duration)
}, 20)
}
alertTimeout2 = setTimeout(function() {
function alertHide (callback) {
clearTimeout(alertTimeout1)
clearTimeout(alertTimeout2)
alertHide(function() {
// Nothing
});
alertOuter.style.top = '-' + alertOuter.offsetHeight - 5 + 'px'
}, duration);
setTimeout(function () {
removeClass(alertOuter, 'notie-transition')
}, 20);
}
alertOuter.style.top = '-10000px'
function alertHide(callback) {
alertIsShowing = false
alertOuter.style.top = '-' + alertOuter.offsetHeight - 5 + 'px';
if (callback) callback()
}, (options.animationDelay + 10))
}
setTimeout(function() {
removeClass(alertOuter, 'notie-transition');
alertOuter.style.top = '-10000px';
// confirm
// **************
alertIsShowing = false;
var confirmOuter = document.createElement('div')
confirmOuter.id = 'notie-confirm-outer'
if (callback) { callback(); }
var confirmInner = document.createElement('div')
confirmInner.id = 'notie-confirm-inner'
confirmOuter.appendChild(confirmInner)
}, (options.animationDelay + 10));
var confirmText = document.createElement('span')
confirmText.id = 'notie-confirm-text'
confirmInner.appendChild(confirmText)
var confirmYes = document.createElement('div')
confirmYes.id = 'notie-confirm-yes'
confirmOuter.appendChild(confirmYes)
var confirmNo = document.createElement('div')
confirmNo.id = 'notie-confirm-no'
confirmOuter.appendChild(confirmNo)
var confirmTextYes = document.createElement('span')
confirmTextYes.id = 'notie-confirm-text-yes'
confirmYes.appendChild(confirmTextYes)
var confirmTextNo = document.createElement('span')
confirmTextNo.id = 'notie-confirm-text-no'
confirmNo.appendChild(confirmTextNo)
var confirmBackground = document.createElement('div')
confirmBackground.id = 'notie-confirm-background'
addClass(confirmBackground, 'notie-transition')
// Hide notie.confirm on no click and background click
confirmBackground.onclick = function () {
if (options.backgroundClickDismiss) {
confirmHide()
}
// confirm
// **************
var confirmOuter = document.createElement('div');
confirmOuter.id = 'notie-confirm-outer';
var confirmInner = document.createElement('div');
confirmInner.id = 'notie-confirm-inner';
confirmOuter.appendChild(confirmInner);
var confirmText = document.createElement('span');
confirmText.id = 'notie-confirm-text';
confirmInner.appendChild(confirmText);
var confirmYes = document.createElement('div');
confirmYes.id = 'notie-confirm-yes'
confirmOuter.appendChild(confirmYes);
}
var confirmNo = document.createElement('div');
confirmNo.id = 'notie-confirm-no';
confirmOuter.appendChild(confirmNo);
var confirmTextYes = document.createElement('span');
confirmTextYes.id = 'notie-confirm-text-yes';
confirmYes.appendChild(confirmTextYes);
// Attach confirm elements to the body element
document.body.appendChild(confirmOuter)
document.body.appendChild(confirmBackground)
var confirmTextNo = document.createElement('span');
confirmTextNo.id = 'notie-confirm-text-no';
confirmNo.appendChild(confirmTextNo);
var confirmBackground = document.createElement('div');
confirmBackground.id = 'notie-confirm-background';
addClass(confirmBackground, 'notie-transition');
// Hide notie.confirm on no click and background click
confirmBackground.onclick = function() {
if (options.backgroundClickDismiss) {
confirmHide();
}
};
// Attach confirm elements to the body element
document.body.appendChild(confirmOuter);
document.body.appendChild(confirmBackground);
// confirm helper variables
var confirmIsShowing = false;
var confirmIsShowing = false
function confirm(title, yesText, noText, yesCallback, noCallback) {
if (options.colorInfo.length > 0) confirmInner.style.backgroundColor = options.colorInfo;
if (options.colorSuccess.length > 0) confirmYes.style.backgroundColor = options.colorSuccess;
if (options.colorError.length > 0) confirmNo.style.backgroundColor = options.colorError;
if (options.colorText.length > 0) {
confirmText.style.color = options.colorText;
confirmTextYes.style.color = options.colorText;
confirmTextNo.style.color = options.colorText;
}
blur();
if (alertIsShowing) {
// Hide notie.alert
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
alertHide(function() {
confirmShow(title, yesText, noText, yesCallback, noCallback);
});
}
else {
confirmShow(title, yesText, noText, yesCallback, noCallback);
}
function confirm (title, yesText, noText, yesCallback, noCallback) {
if (options.colorInfo.length > 0) confirmInner.style.backgroundColor = options.colorInfo
if (options.colorSuccess.length > 0) confirmYes.style.backgroundColor = options.colorSuccess
if (options.colorError.length > 0) confirmNo.style.backgroundColor = options.colorError
if (options.colorText.length > 0) {
confirmText.style.color = options.colorText
confirmTextYes.style.color = options.colorText
confirmTextNo.style.color = options.colorText
}
blur()
if (alertIsShowing) {
// Hide notie.alert
alertHide(function () {
confirmShow(title, yesText, noText, yesCallback, noCallback)
})
} else {
confirmShow(title, yesText, noText, yesCallback, noCallback)
}
function confirmShow(title, yesText, noText, yesCallback, noCallback) {
}
scrollDisable();
function confirmShow (title, yesText, noText, yesCallback, noCallback) {
scrollDisable()
// Yes callback function
confirmYes.onclick = function() {
confirmHide();
if (yesCallback) {
setTimeout(function() {
yesCallback();
}, (options.animationDelay + 10));
}
}
// No callback function
confirmNo.onclick = function() {
confirmHide();
if (noCallback) {
setTimeout(function() {
noCallback();
}, (options.animationDelay + 10));
}
}
// Yes callback function
confirmYes.onclick = function () {
confirmHide()
if (yesCallback) {
setTimeout(function () {
yesCallback()
}, (options.animationDelay + 10))
}
}
function confirmShowInner() {
// No callback function
confirmNo.onclick = function () {
confirmHide()
if (noCallback) {
setTimeout(function () {
noCallback()
}, (options.animationDelay + 10))
}
}
// Set confirm text
confirmText.innerHTML = title;
confirmTextYes.innerHTML = yesText;
confirmTextNo.innerHTML = noText;
function confirmShowInner () {
// Set confirm text
confirmText.innerHTML = title
confirmTextYes.innerHTML = yesText
confirmTextNo.innerHTML = noText
// Get confirm's height
confirmOuter.style.top = '-10000px';
confirmOuter.style.display = 'table';
confirmOuter.style.top = '-' + confirmOuter.offsetHeight - 5 + 'px';
confirmBackground.style.display = 'block';
// Get confirm's height
confirmOuter.style.top = '-10000px'
confirmOuter.style.display = 'table'
confirmOuter.style.top = '-' + confirmOuter.offsetHeight - 5 + 'px'
confirmBackground.style.display = 'block'
setTimeout(function() {
addClass(confirmOuter, 'notie-transition');
setTimeout(function () {
addClass(confirmOuter, 'notie-transition')
confirmOuter.style.top = 0;
confirmBackground.style.opacity = '0.75';
confirmOuter.style.top = 0
confirmBackground.style.opacity = '0.75'
setTimeout(function() {
confirmIsShowing = true;
}, (options.animationDelay + 10));
setTimeout(function () {
confirmIsShowing = true
}, (options.animationDelay + 10))
}, 20)
}
}, 20);
if (confirmIsShowing) {
confirmHide()
setTimeout(function () {
confirmShowInner()
}, (options.animationDelay + 10))
} else {
confirmShowInner()
}
}
}
function confirmHide () {
confirmOuter.style.top = '-' + confirmOuter.offsetHeight - 5 + 'px'
confirmBackground.style.opacity = '0'
if (confirmIsShowing) {
confirmHide();
setTimeout(function() {
confirmShowInner();
}, (options.animationDelay + 10));
}
else {
confirmShowInner();
}
setTimeout(function () {
removeClass(confirmOuter, 'notie-transition')
confirmOuter.style.top = '-10000px'
confirmBackground.style.display = 'none'
}
scrollEnable()
function confirmHide() {
confirmIsShowing = false
}, (options.animationDelay + 10))
}
confirmOuter.style.top = '-' + confirmOuter.offsetHeight - 5 + 'px';
confirmBackground.style.opacity = '0';
// input
// **********
setTimeout(function() {
removeClass(confirmOuter, 'notie-transition');
confirmOuter.style.top = '-10000px';
confirmBackground.style.display = 'none';
var inputOuter = document.createElement('div')
inputOuter.id = 'notie-input-outer'
scrollEnable();
var inputBackground = document.createElement('div')
inputBackground.id = 'notie-input-background'
addClass(inputBackground, 'notie-transition')
confirmIsShowing = false;
var inputInner = document.createElement('div')
inputInner.id = 'notie-input-inner'
inputOuter.appendChild(inputInner)
}, (options.animationDelay + 10));
var inputField = document.createElement('input')
inputField.id = 'notie-input-field'
inputField.setAttribute('autocomplete', 'off')
inputField.setAttribute('autocorrect', 'off')
inputField.setAttribute('autocapitalize', 'off')
inputField.setAttribute('spellcheck', 'false')
inputOuter.appendChild(inputField)
}
// input
// **********
var inputYes = document.createElement('div')
inputYes.id = 'notie-input-yes'
inputOuter.appendChild(inputYes)
var inputOuter = document.createElement('div');
inputOuter.id = 'notie-input-outer';
var inputBackground = document.createElement('div');
inputBackground.id = 'notie-input-background';
addClass(inputBackground, 'notie-transition');
var inputInner = document.createElement('div');
inputInner.id = 'notie-input-inner';
inputOuter.appendChild(inputInner);
var inputField = document.createElement('input');
inputField.id = 'notie-input-field';
inputField.setAttribute('autocomplete', 'off');
inputField.setAttribute('autocorrect', 'off');
inputField.setAttribute('autocapitalize', 'off');
inputField.setAttribute('spellcheck', 'false');
inputOuter.appendChild(inputField);
var inputYes = document.createElement('div');
inputYes.id = 'notie-input-yes';
inputOuter.appendChild(inputYes);
var inputNo = document.createElement('div')
inputNo.id = 'notie-input-no'
inputOuter.appendChild(inputNo)
var inputNo = document.createElement('div');
inputNo.id = 'notie-input-no';
inputOuter.appendChild(inputNo);
var inputText = document.createElement('span');
inputText.id = 'notie-input-text';
inputInner.appendChild(inputText);
var inputText = document.createElement('span')
inputText.id = 'notie-input-text'
inputInner.appendChild(inputText)
var inputTextYes = document.createElement('span');
inputTextYes.id = 'notie-input-text-yes';
inputYes.appendChild(inputTextYes);
var inputTextYes = document.createElement('span')
inputTextYes.id = 'notie-input-text-yes'
inputYes.appendChild(inputTextYes)
var inputTextNo = document.createElement('span');
inputTextNo.id = 'notie-input-text-no';
inputNo.appendChild(inputTextNo);
var inputTextNo = document.createElement('span')
inputTextNo.id = 'notie-input-text-no'
inputNo.appendChild(inputTextNo)
// Attach input elements to the body element
document.body.appendChild(inputOuter);
document.body.appendChild(inputBackground);
// Hide input on no click and background click
inputBackground.onclick = function() {
if (options.backgroundClickDismiss) {
inputHide();
}
};
// input helper variables
var inputIsShowing = false;
function input(settings, title, submitText, cancelText, submitCallback, cancelCallback) {
if (options.colorInfo.length > 0) inputInner.style.backgroundColor = options.colorInfo;
if (options.colorSuccess.length > 0) inputYes.style.backgroundColor = options.colorSuccess;
if (options.colorError.length > 0) inputNo.style.backgroundColor = options.colorError;
if (options.colorText.length > 0) {
inputText.style.color = options.colorText;
inputTextYes.style.color = options.colorText;
inputTextNo.style.color = options.colorText;
}
blur();
if (typeof settings.type !== 'undefined' && settings.type) {
inputField.setAttribute('type', settings.type);
}
else {
inputField.setAttribute('type', 'text');
}
if (typeof settings.placeholder !== 'undefined' && settings.placeholder) {
inputField.setAttribute('placeholder', settings.placeholder);
}
else {
// Do not set placeholder
}
if (typeof settings.prefilledValue !== 'undefined' && settings.prefilledValue) {
inputField.value = settings.prefilledValue;
}
else {
inputField.value = '';
}
if (alertIsShowing) {
// Hide alert
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
alertHide(function() {
inputShow(title, submitText, cancelText, submitCallback, cancelCallback);
});
}
else {
inputShow(title, submitText, cancelText, submitCallback, cancelCallback);
}
// Attach input elements to the body element
document.body.appendChild(inputOuter)
document.body.appendChild(inputBackground)
// Hide input on no click and background click
inputBackground.onclick = function () {
if (options.backgroundClickDismiss) {
inputHide()
}
function inputShow(title, submitText, cancelText, submitCallback, cancelCallback) {
}
scrollDisable();
// input helper variables
var inputIsShowing = false
// Yes callback function
inputYes.onclick = function() {
inputHide();
if (submitCallback) {
setTimeout(function() {
submitCallback(inputField.value);
}, (options.animationDelay + 10));
}
}
// No callback function
inputNo.onclick = function() {
inputHide();
if (cancelCallback) {
setTimeout(function() {
cancelCallback(inputField.value);
}, (options.animationDelay + 10));
}
}
function input (settings, title, submitText, cancelText, submitCallback, cancelCallback) {
if (options.colorInfo.length > 0) inputInner.style.backgroundColor = options.colorInfo
if (options.colorSuccess.length > 0) inputYes.style.backgroundColor = options.colorSuccess
if (options.colorError.length > 0) inputNo.style.backgroundColor = options.colorError
if (options.colorText.length > 0) {
inputText.style.color = options.colorText
inputTextYes.style.color = options.colorText
inputTextNo.style.color = options.colorText
}
function inputShowInner() {
blur()
// Set input text
inputText.innerHTML = title;
inputTextYes.innerHTML = submitText;
inputTextNo.innerHTML = cancelText;
if (typeof settings.type !== 'undefined' && settings.type) {
inputField.setAttribute('type', settings.type)
} else {
inputField.setAttribute('type', 'text')
}
// Get input's height
inputOuter.style.top = '-10000px';
inputOuter.style.display = 'table';
inputOuter.style.top = '-' + inputOuter.offsetHeight - 5 + 'px';
inputBackground.style.display = 'block';
if (typeof settings.placeholder !== 'undefined' && settings.placeholder) {
inputField.setAttribute('placeholder', settings.placeholder)
} else {
// Do not set placeholder
}
setTimeout(function() {
if (typeof settings.prefilledValue !== 'undefined' && settings.prefilledValue) {
inputField.value = settings.prefilledValue
} else {
inputField.value = ''
}
addClass(inputOuter, 'notie-transition');
inputOuter.style.top = 0;
inputBackground.style.opacity = '0.75';
if (alertIsShowing) {
// Hide alert
alertHide(function () {
inputShow(title, submitText, cancelText, submitCallback, cancelCallback)
})
} else {
inputShow(title, submitText, cancelText, submitCallback, cancelCallback)
}
}
setTimeout(function() {
inputIsShowing = true;
// put focus on input field
inputField.focus();
}, (options.animationDelay + 10));
function inputShow (title, submitText, cancelText, submitCallback, cancelCallback) {
scrollDisable()
}, 20);
// Yes callback function
inputYes.onclick = function () {
inputHide()
if (submitCallback) {
setTimeout(function () {
submitCallback(inputField.value)
}, (options.animationDelay + 10))
}
}
}
// No callback function
inputNo.onclick = function () {
inputHide()
if (cancelCallback) {
setTimeout(function () {
cancelCallback(inputField.value)
}, (options.animationDelay + 10))
}
}
if (inputIsShowing) {
inputHide();
setTimeout(function() {
inputShowInner();
}, (options.animationDelay + 10));
}
else {
inputShowInner();
}
function inputShowInner () {
// Set input text
inputText.innerHTML = title
inputTextYes.innerHTML = submitText
inputTextNo.innerHTML = cancelText
// Get input's height
inputOuter.style.top = '-10000px'
inputOuter.style.display = 'table'
inputOuter.style.top = '-' + inputOuter.offsetHeight - 5 + 'px'
inputBackground.style.display = 'block'
setTimeout(function () {
addClass(inputOuter, 'notie-transition')
inputOuter.style.top = 0
inputBackground.style.opacity = '0.75'
setTimeout(function () {
inputIsShowing = true
// put focus on input field
inputField.focus()
}, (options.animationDelay + 10))
}, 20)
}
function inputHide() {
if (inputIsShowing) {
inputHide()
setTimeout(function () {
inputShowInner()
}, (options.animationDelay + 10))
} else {
inputShowInner()
}
}
inputOuter.style.top = '-' + inputOuter.offsetHeight - 5 + 'px';
inputBackground.style.opacity = '0';
function inputHide () {
inputOuter.style.top = '-' + inputOuter.offsetHeight - 5 + 'px'
inputBackground.style.opacity = '0'
setTimeout(function() {
removeClass(inputOuter, 'notie-transition');
inputBackground.style.display = 'none';
inputOuter.style.top = '-10000px';
setTimeout(function () {
removeClass(inputOuter, 'notie-transition')
inputBackground.style.display = 'none'
scrollEnable();
inputOuter.style.top = '-10000px'
inputIsShowing = false;
scrollEnable()
}, (options.animationDelay + 10));
inputIsShowing = false
}, (options.animationDelay + 10))
}
// select
// **************
var selectOuter = document.createElement('div')
selectOuter.id = 'notie-select-outer'
var selectInner = document.createElement('div')
selectInner.id = 'notie-select-inner'
selectOuter.appendChild(selectInner)
var selectText = document.createElement('span')
selectText.id = 'notie-select-text'
selectInner.appendChild(selectText)
var selectBackground = document.createElement('div')
selectBackground.id = 'notie-select-background'
addClass(selectBackground, 'notie-transition')
var selectChoices = document.createElement('div')
selectChoices.id = 'notie-select-choices'
selectOuter.appendChild(selectChoices)
var selectCancel = document.createElement('div')
selectCancel.id = 'notie-select-cancel'
selectCancel.innerHTML = 'Cancel'
selectOuter.appendChild(selectCancel)
// Attach select elements to the body element
document.body.appendChild(selectOuter)
document.body.appendChild(selectBackground)
// Hide input on no click and background click
selectBackground.onclick = function () {
if (options.backgroundClickDismiss) {
selectHide()
}
// select
// **************
var selectOuter = document.createElement('div');
selectOuter.id = 'notie-select-outer';
var selectInner = document.createElement('div');
selectInner.id = 'notie-select-inner';
selectOuter.appendChild(selectInner);
var selectText = document.createElement('span');
selectText.id = 'notie-select-text';
selectInner.appendChild(selectText);
var selectBackground = document.createElement('div');
selectBackground.id = 'notie-select-background';
addClass(selectBackground, 'notie-transition');
var selectChoices = document.createElement('div');
selectChoices.id = 'notie-select-choices';
selectOuter.appendChild(selectChoices);
var selectCancel = document.createElement('div');
selectCancel.id = 'notie-select-cancel';
selectCancel.innerHTML = 'Cancel';
selectOuter.appendChild(selectCancel);
// Attach select elements to the body element
document.body.appendChild(selectOuter);
document.body.appendChild(selectBackground);
// Hide input on no click and background click
selectBackground.onclick = function() {
if (options.backgroundClickDismiss) {
selectHide();
}
};
selectCancel.onclick = function() {
selectHide();
}
// select helper variables
var selectIsShowing = false;
function select(title, choices /*, callback1, callback2, ... */) {
if (options.colorInfo.length > 0) selectInner.style.backgroundColor = options.colorInfo;
if (options.colorNeutral.length > 0) selectCancel.style.backgroundColor = options.colorNeutral;
if (options.colorText.length > 0) {
selectText.style.color = options.colorText;
selectCancel.style.color = options.colorText;
}
var funcs = [];
for (var i = 0; i < arguments.length - 2; i++) {
funcs[i] = arguments[i + 2];
}
if (funcs.length === choices.length) {
blur();
if (alertIsShowing) {
// Hide notie.alert
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
alertHide(function() {
selectShow(title, choices, funcs);
});
}
else {
selectShow(title, choices, funcs);
}
}
else {
throw 'notie.select number of choices must match number of functions';
}
}
selectCancel.onclick = function () {
selectHide()
}
// select helper variables
var selectIsShowing = false
function select (title, choices /*, callback1, callback2, ... */) {
if (options.colorInfo.length > 0) selectInner.style.backgroundColor = options.colorInfo
if (options.colorNeutral.length > 0) selectCancel.style.backgroundColor = options.colorNeutral
if (options.colorText.length > 0) {
selectText.style.color = options.colorText
selectCancel.style.color = options.colorText
}
function selectShow(title, choices, funcs) {
scrollDisable();
document.getElementById('notie-select-choices').innerHTML = '';
var selectChoicePrevious;
for (var i = 0; i < choices.length; i++) {
var selectChoice = document.createElement('div');
selectChoice.innerHTML = choices[i].title;
addClass(selectChoice, 'notie-select-choice');
selectChoices.appendChild(selectChoice);
selectChoice.style.backgroundColor = window.getComputedStyle(selectChoice).backgroundColor;
if (options.colorText.length > 0) selectChoice.style.color = options.colorText;
if (choices[i].type) {
switch(choices[i].type) {
case 1:
if (options.colorSuccess.length > 0) selectChoice.style.backgroundColor = options.colorSuccess;
else addClass(selectChoice, 'notie-background-success');
break;
case 2:
if (options.colorWarning.length > 0) selectChoice.style.backgroundColor = options.colorWarning;
else addClass(selectChoice, 'notie-background-warning');
break;
case 3:
if (options.colorError.length > 0) selectChoice.style.backgroundColor = options.colorError;
else addClass(selectChoice, 'notie-background-error');
break;
case 4:
if (options.colorInfo.length > 0) selectChoice.style.backgroundColor = options.colorInfo;
else addClass(selectChoice, 'notie-background-info');
break;
}
}
else if (choices[i].color) {
selectChoice.style.backgroundColor = choices[i].color;
}
if (i > 0) {
if (selectChoice.style.backgroundColor === selectChoicePrevious.style.backgroundColor) {
selectChoicePrevious.style.borderBottom = '1px solid rgba(255, 255, 255, 0.2)';
}
}
// onclick for this choice
selectChoice.onclick = (function(i) { return function() {
selectHide();
setTimeout(function() {
funcs[i]();
}, (options.animationDelay + 10));
};})(i);
selectChoicePrevious = selectChoice;
}
function selectShowInner(title) {
var funcs = []
for (var i = 0; i < arguments.length - 2; i++) {
funcs[i] = arguments[i + 2]
}
// Set select text
selectText.innerHTML = title;
if (funcs.length === choices.length) {
blur()
// Get select's height
selectOuter.style.bottom = '-10000px';
selectOuter.style.display = 'table';
selectOuter.style.bottom = '-' + selectOuter.offsetHeight - 5 + 'px';
selectBackground.style.display = 'block';
if (alertIsShowing) {
// Hide notie.alert
alertHide(function () {
selectShow(title, choices, funcs)
})
} else {
selectShow(title, choices, funcs)
}
} else {
throw new Error('notie.select number of choices must match number of functions')
}
}
setTimeout(function() {
addClass(selectOuter, 'notie-transition');
function selectShow (title, choices, funcs) {
scrollDisable()
selectOuter.style.bottom = 0;
selectBackground.style.opacity = '0.75';
document.getElementById('notie-select-choices').innerHTML = ''
setTimeout(function() {
selectIsShowing = true;
}, (options.animationDelay + 10));
var selectChoicePrevious
}, 20);
for (var i = 0; i < choices.length; i++) {
var selectChoice = document.createElement('div')
selectChoice.innerHTML = choices[i].title
addClass(selectChoice, 'notie-select-choice')
selectChoices.appendChild(selectChoice)
selectChoice.style.backgroundColor = window.getComputedStyle(selectChoice).backgroundColor
if (options.colorText.length > 0) selectChoice.style.color = options.colorText
if (choices[i].type) {
switch (choices[i].type) {
case 1:
if (options.colorSuccess.length > 0) selectChoice.style.backgroundColor = options.colorSuccess
else addClass(selectChoice, 'notie-background-success')
break
case 2:
if (options.colorWarning.length > 0) selectChoice.style.backgroundColor = options.colorWarning
else addClass(selectChoice, 'notie-background-warning')
break
case 3:
if (options.colorError.length > 0) selectChoice.style.backgroundColor = options.colorError
else addClass(selectChoice, 'notie-background-error')
break
case 4:
if (options.colorInfo.length > 0) selectChoice.style.backgroundColor = options.colorInfo
else addClass(selectChoice, 'notie-background-info')
break
}
} else if (choices[i].color) {
selectChoice.style.backgroundColor = choices[i].color
}
if (selectIsShowing) {
selectHide();
setTimeout(function() {
selectShowInner(title);
}, (options.animationDelay + 10));
if (i > 0 && selectChoice.style.backgroundColor === selectChoicePrevious.style.backgroundColor) {
selectChoicePrevious.style.borderBottom = '1px solid rgba(255, 255, 255, 0.2)'
}
// onclick for this choice
selectChoice.onclick = (function (i) {
return function () {
selectHide()
setTimeout(function () {
funcs[i]()
}, (options.animationDelay + 10))
}
else {
selectShowInner(title);
}
}
function selectHide() {
selectOuter.style.bottom = '-' + selectOuter.offsetHeight - 5 + 'px';
selectBackground.style.opacity = '0';
})(i)
setTimeout(function() {
removeClass(selectOuter, 'notie-transition');
selectOuter.style.bottom = '-10000px';
selectBackground.style.display = 'none';
selectChoicePrevious = selectChoice
}
scrollEnable();
function selectShowInner (title) {
// Set select text
selectText.innerHTML = title
selectIsShowing = false;
// Get select's height
selectOuter.style.bottom = '-10000px'
selectOuter.style.display = 'table'
selectOuter.style.bottom = '-' + selectOuter.offsetHeight - 5 + 'px'
selectBackground.style.display = 'block'
}, (options.animationDelay + 10));
}
// Internal helper functions
// #################
function addClass(element, className) {
if (element.classList) {
element.classList.add(className);
}
else {
element.className += ' ' + className;
}
}
function removeClass(element, className) {
if (element.classList) {
element.classList.remove(className);
}
else {
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
}
function blur() {
document.activeElement.blur();
}
var originalBodyHeight, originalBodyOverflow;
function scrollDisable() {
originalBodyHeight = document.body.style.height;
originalBodyOverflow = document.body.style.overflow;
document.body.style.height = '100%';
document.body.style.overflow = 'hidden';
setTimeout(function () {
addClass(selectOuter, 'notie-transition')
selectOuter.style.bottom = 0
selectBackground.style.opacity = '0.75'
setTimeout(function () {
selectIsShowing = true
}, (options.animationDelay + 10))
}, 20)
}
function scrollEnable() {
document.body.style.height = originalBodyHeight;
document.body.style.overflow = originalBodyOverflow;
if (selectIsShowing) {
selectHide()
setTimeout(function () {
selectShowInner(title)
}, (options.animationDelay + 10))
} else {
selectShowInner(title)
}
// Event listener for keydown enter and escape keys
window.addEventListener('keydown', function(event) {
var enterClicked = (event.which == 13 || event.keyCode == 13);
var escapeClicked = (event.which == 27 || event.keyCode == 27);
if (alertIsShowing) {
if (enterClicked || escapeClicked) {
clearTimeout(alertTimeout1);
clearTimeout(alertTimeout2);
alertHide();
}
}
else if (confirmIsShowing) {
if (enterClicked) {
confirmYes.click();
}
else if (escapeClicked) {
confirmHide();
}
}
else if (inputIsShowing) {
if (enterClicked) {
inputYes.click();
}
else if (escapeClicked) {
inputHide();
}
}
else if (selectIsShowing) {
if (escapeClicked) {
selectHide();
}
}
});
return {
setOptions: setOptions,
alert: alert,
confirm: confirm,
input: input,
select: select
};
}
}();
function selectHide () {
selectOuter.style.bottom = '-' + selectOuter.offsetHeight - 5 + 'px'
selectBackground.style.opacity = '0'
setTimeout(function () {
removeClass(selectOuter, 'notie-transition')
selectOuter.style.bottom = '-10000px'
selectBackground.style.display = 'none'
scrollEnable()
selectIsShowing = false
}, (options.animationDelay + 10))
}
function isShowing () {
return alertIsShowing || confirmIsShowing || inputIsShowing || selectIsShowing
}
// Internal helper functions
// #################
function addClass (element, className) {
if (element.classList) {
element.classList.add(className)
} else {
element.className += ' ' + className
}
}
function removeClass (element, className) {
if (element.classList) {
element.classList.remove(className)
} else {
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ')
}
}
function blur () {
document.activeElement && document.activeElement.blur()
}
var originalBodyHeight, originalBodyOverflow
function scrollDisable () {
originalBodyHeight = document.body.style.height
originalBodyOverflow = document.body.style.overflow
document.body.style.height = '100%'
document.body.style.overflow = 'hidden'
}
function scrollEnable () {
document.body.style.height = originalBodyHeight
document.body.style.overflow = originalBodyOverflow
}
// Event listener for keydown enter and escape keys
window.addEventListener('keydown', function (event) {
var enterClicked = (event.which === 13 || event.keyCode === 13)
var escapeClicked = (event.which === 27 || event.keyCode === 27)
if (alertIsShowing) {
if (enterClicked || escapeClicked) {
alertHide()
}
} else if (confirmIsShowing) {
if (enterClicked) {
confirmYes.click()
} else if (escapeClicked) {
confirmHide()
}
} else if (inputIsShowing) {
if (enterClicked) {
inputYes.click()
} else if (escapeClicked) {
inputHide()
}
} else if (selectIsShowing) {
if (escapeClicked) {
selectHide()
}
}
})
return {
setOptions: setOptions,
alert: alert,
alertHide: alertHide,
confirm: confirm,
input: input,
select: select,
isShowing: isShowing
}
}())
// Node.js
if (typeof module === 'object' && module.exports) {
module.exports = notie;
}
module.exports = notie
}

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

var notie=function(){function e(e){for(var t in e)h[t]=e[t]}function t(e,t,i){h.colorText.length>0&&(C.style.color=h.colorText),f(),H++,setTimeout(function(){H--},h.animationDelay+10),1===H&&(D?(clearTimeout(x),clearTimeout(E),n(function(){o(e,t,i)})):o(e,t,i))}function o(e,t,o){D=!0;var i=0;if("undefined"==typeof o||0===o)var i=864e5;else i=o>0&&1>o?1e3:1e3*o;switch(y(k,"notie-background-success"),y(k,"notie-background-warning"),y(k,"notie-background-error"),y(k,"notie-background-info"),e){case 1:h.colorSuccess.length>0?k.style.backgroundColor=h.colorSuccess:p(k,"notie-background-success");break;case 2:h.colorWarning.length>0?k.style.backgroundColor=h.colorWarning:p(k,"notie-background-warning");break;case 3:h.colorError.length>0?k.style.backgroundColor=h.colorError:p(k,"notie-background-error");break;case 4:h.colorInfo.length>0?k.style.backgroundColor=h.colorInfo:p(k,"notie-background-info")}C.innerHTML=t,k.style.top="-10000px",k.style.display="table",k.style.top="-"+k.offsetHeight-5+"px",x=setTimeout(function(){p(k,"notie-transition"),k.style.top=0,E=setTimeout(function(){n(function(){})},i)},20)}function n(e){k.style.top="-"+k.offsetHeight-5+"px",setTimeout(function(){y(k,"notie-transition"),k.style.top="-10000px",D=!1,e&&e()},h.animationDelay+10)}function i(e,t,o,i,l){h.colorInfo.length>0&&(L.style.backgroundColor=h.colorInfo),h.colorSuccess.length>0&&(M.style.backgroundColor=h.colorSuccess),h.colorError.length>0&&(S.style.backgroundColor=h.colorError),h.colorText.length>0&&(I.style.color=h.colorText,A.style.color=h.colorText,N.style.color=h.colorText),f(),D?(clearTimeout(x),clearTimeout(E),n(function(){c(e,t,o,i,l)})):c(e,t,o,i,l)}function c(e,t,o,n,i){function c(){I.innerHTML=e,A.innerHTML=t,N.innerHTML=o,w.style.top="-10000px",w.style.display="table",w.style.top="-"+w.offsetHeight-5+"px",W.style.display="block",setTimeout(function(){p(w,"notie-transition"),w.style.top=0,W.style.opacity="0.75",setTimeout(function(){V=!0},h.animationDelay+10)},20)}g(),M.onclick=function(){l(),n&&setTimeout(function(){n()},h.animationDelay+10)},S.onclick=function(){l(),i&&setTimeout(function(){i()},h.animationDelay+10)},V?(l(),setTimeout(function(){c()},h.animationDelay+10)):c()}function l(){w.style.top="-"+w.offsetHeight-5+"px",W.style.opacity="0",setTimeout(function(){y(w,"notie-transition"),w.style.top="-10000px",W.style.display="none",b(),V=!1},h.animationDelay+10)}function r(e,t,o,i,c,l){h.colorInfo.length>0&&(z.style.backgroundColor=h.colorInfo),h.colorSuccess.length>0&&(R.style.backgroundColor=h.colorSuccess),h.colorError.length>0&&($.style.backgroundColor=h.colorError),h.colorText.length>0&&(q.style.color=h.colorText,F.style.color=h.colorText,G.style.color=h.colorText),f(),"undefined"!=typeof e.type&&e.type?O.setAttribute("type",e.type):O.setAttribute("type","text"),"undefined"!=typeof e.placeholder&&e.placeholder&&O.setAttribute("placeholder",e.placeholder),"undefined"!=typeof e.prefilledValue&&e.prefilledValue?O.value=e.prefilledValue:O.value="",D?(clearTimeout(x),clearTimeout(E),n(function(){a(t,o,i,c,l)})):a(t,o,i,c,l)}function a(e,t,o,n,i){function c(){q.innerHTML=e,F.innerHTML=t,G.innerHTML=o,j.style.top="-10000px",j.style.display="table",j.style.top="-"+j.offsetHeight-5+"px",B.style.display="block",setTimeout(function(){p(j,"notie-transition"),j.style.top=0,B.style.opacity="0.75",setTimeout(function(){J=!0,O.focus()},h.animationDelay+10)},20)}g(),R.onclick=function(){d(),n&&setTimeout(function(){n(O.value)},h.animationDelay+10)},$.onclick=function(){d(),i&&setTimeout(function(){i(O.value)},h.animationDelay+10)},J?(d(),setTimeout(function(){c()},h.animationDelay+10)):c()}function d(){j.style.top="-"+j.offsetHeight-5+"px",B.style.opacity="0",setTimeout(function(){y(j,"notie-transition"),B.style.display="none",j.style.top="-10000px",b(),J=!1},h.animationDelay+10)}function u(e,t){h.colorInfo.length>0&&(P.style.backgroundColor=h.colorInfo),h.colorNeutral.length>0&&(Y.style.backgroundColor=h.colorNeutral),h.colorText.length>0&&(Q.style.color=h.colorText,Y.style.color=h.colorText);for(var o=[],i=0;i<arguments.length-2;i++)o[i]=arguments[i+2];if(o.length!==t.length)throw"notie.select number of choices must match number of functions";f(),D?(clearTimeout(x),clearTimeout(E),n(function(){s(e,t,o)})):s(e,t,o)}function s(e,t,o){function n(e){Q.innerHTML=e,K.style.bottom="-10000px",K.style.display="table",K.style.bottom="-"+K.offsetHeight-5+"px",U.style.display="block",setTimeout(function(){p(K,"notie-transition"),K.style.bottom=0,U.style.opacity="0.75",setTimeout(function(){ee=!0},h.animationDelay+10)},20)}g(),document.getElementById("notie-select-choices").innerHTML="";for(var i,c=0;c<t.length;c++){var l=document.createElement("div");if(l.innerHTML=t[c].title,p(l,"notie-select-choice"),X.appendChild(l),l.style.backgroundColor=window.getComputedStyle(l).backgroundColor,h.colorText.length>0&&(l.style.color=h.colorText),t[c].type)switch(t[c].type){case 1:h.colorSuccess.length>0?l.style.backgroundColor=h.colorSuccess:p(l,"notie-background-success");break;case 2:h.colorWarning.length>0?l.style.backgroundColor=h.colorWarning:p(l,"notie-background-warning");break;case 3:h.colorError.length>0?l.style.backgroundColor=h.colorError:p(l,"notie-background-error");break;case 4:h.colorInfo.length>0?l.style.backgroundColor=h.colorInfo:p(l,"notie-background-info")}else t[c].color&&(l.style.backgroundColor=t[c].color);c>0&&l.style.backgroundColor===i.style.backgroundColor&&(i.style.borderBottom="1px solid rgba(255, 255, 255, 0.2)"),l.onclick=function(e){return function(){m(),setTimeout(function(){o[e]()},h.animationDelay+10)}}(c),i=l}ee?(m(),setTimeout(function(){n(e)},h.animationDelay+10)):n(e)}function m(){K.style.bottom="-"+K.offsetHeight-5+"px",U.style.opacity="0",setTimeout(function(){y(K,"notie-transition"),K.style.bottom="-10000px",U.style.display="none",b(),ee=!1},h.animationDelay+10)}function p(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function y(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function f(){document.activeElement.blur()}function g(){Z=document.body.style.height,_=document.body.style.overflow,document.body.style.height="100%",document.body.style.overflow="hidden"}function b(){document.body.style.height=Z,document.body.style.overflow=_}var h={colorSuccess:"",colorWarning:"",colorError:"",colorInfo:"",colorNeutral:"",colorText:"",animationDelay:300,backgroundClickDismiss:!0},k=document.createElement("div");k.id="notie-alert-outer",k.onclick=function(){clearTimeout(x),clearTimeout(E),n()},document.body.appendChild(k);var v=document.createElement("div");v.id="notie-alert-inner",k.appendChild(v);var T=document.createElement("div");T.id="notie-alert-content",v.appendChild(T);var C=document.createElement("span");C.id="notie-alert-text",T.appendChild(C);var x,E,D=!1,H=0,w=document.createElement("div");w.id="notie-confirm-outer";var L=document.createElement("div");L.id="notie-confirm-inner",w.appendChild(L);var I=document.createElement("span");I.id="notie-confirm-text",L.appendChild(I);var M=document.createElement("div");M.id="notie-confirm-yes",w.appendChild(M);var S=document.createElement("div");S.id="notie-confirm-no",w.appendChild(S);var A=document.createElement("span");A.id="notie-confirm-text-yes",M.appendChild(A);var N=document.createElement("span");N.id="notie-confirm-text-no",S.appendChild(N);var W=document.createElement("div");W.id="notie-confirm-background",p(W,"notie-transition"),W.onclick=function(){h.backgroundClickDismiss&&l()},document.body.appendChild(w),document.body.appendChild(W);var V=!1,j=document.createElement("div");j.id="notie-input-outer";var B=document.createElement("div");B.id="notie-input-background",p(B,"notie-transition");var z=document.createElement("div");z.id="notie-input-inner",j.appendChild(z);var O=document.createElement("input");O.id="notie-input-field",O.setAttribute("autocomplete","off"),O.setAttribute("autocorrect","off"),O.setAttribute("autocapitalize","off"),O.setAttribute("spellcheck","false"),j.appendChild(O);var R=document.createElement("div");R.id="notie-input-yes",j.appendChild(R);var $=document.createElement("div");$.id="notie-input-no",j.appendChild($);var q=document.createElement("span");q.id="notie-input-text",z.appendChild(q);var F=document.createElement("span");F.id="notie-input-text-yes",R.appendChild(F);var G=document.createElement("span");G.id="notie-input-text-no",$.appendChild(G),document.body.appendChild(j),document.body.appendChild(B),B.onclick=function(){h.backgroundClickDismiss&&d()};var J=!1,K=document.createElement("div");K.id="notie-select-outer";var P=document.createElement("div");P.id="notie-select-inner",K.appendChild(P);var Q=document.createElement("span");Q.id="notie-select-text",P.appendChild(Q);var U=document.createElement("div");U.id="notie-select-background",p(U,"notie-transition");var X=document.createElement("div");X.id="notie-select-choices",K.appendChild(X);var Y=document.createElement("div");Y.id="notie-select-cancel",Y.innerHTML="Cancel",K.appendChild(Y),document.body.appendChild(K),document.body.appendChild(U),U.onclick=function(){h.backgroundClickDismiss&&m()},Y.onclick=function(){m()};var Z,_,ee=!1;return window.addEventListener("keydown",function(e){var t=13==e.which||13==e.keyCode,o=27==e.which||27==e.keyCode;D?(t||o)&&(clearTimeout(x),clearTimeout(E),n()):V?t?M.click():o&&l():J?t?R.click():o&&d():ee&&o&&m()}),{setOptions:e,alert:t,confirm:i,input:r,select:u}}();"object"==typeof module&&module.exports&&(module.exports=notie);
var notie=function(){function e(e){for(var t in e)k[t]=e[t]}function t(e,t,i){k.colorText.length>0&&(x.style.color=k.colorText),g(),H++,setTimeout(function(){H--},k.animationDelay+10),H>=1&&(w?n(function(){o(e,t,i)}):o(e,t,i))}function o(e,t,o){w=!0;var i=0;switch(i="undefined"==typeof o||0===o?864e5:o>0&&1>o?1e3:1e3*o,f(v,"notie-background-success"),f(v,"notie-background-warning"),f(v,"notie-background-error"),f(v,"notie-background-info"),e){case 1:case"success":k.colorSuccess.length>0?v.style.backgroundColor=k.colorSuccess:y(v,"notie-background-success");break;case 2:case"warning":k.colorWarning.length>0?v.style.backgroundColor=k.colorWarning:y(v,"notie-background-warning");break;case 3:case"error":k.colorError.length>0?v.style.backgroundColor=k.colorError:y(v,"notie-background-error");break;case 4:case"info":k.colorInfo.length>0?v.style.backgroundColor=k.colorInfo:y(v,"notie-background-info")}x.innerHTML=t,v.style.top="-10000px",v.style.display="table",v.style.top="-"+v.offsetHeight-5+"px",E=setTimeout(function(){y(v,"notie-transition"),v.style.top=0,D=setTimeout(function(){n(function(){})},i)},20)}function n(e){clearTimeout(E),clearTimeout(D),v.style.top="-"+v.offsetHeight-5+"px",setTimeout(function(){f(v,"notie-transition"),v.style.top="-10000px",w=!1,e&&e()},k.animationDelay+10)}function i(e,t,o,i,l){k.colorInfo.length>0&&(I.style.backgroundColor=k.colorInfo),k.colorSuccess.length>0&&(S.style.backgroundColor=k.colorSuccess),k.colorError.length>0&&(A.style.backgroundColor=k.colorError),k.colorText.length>0&&(M.style.color=k.colorText,N.style.color=k.colorText,W.style.color=k.colorText),g(),w?n(function(){c(e,t,o,i,l)}):c(e,t,o,i,l)}function c(e,t,o,n,i){function c(){M.innerHTML=e,N.innerHTML=t,W.innerHTML=o,L.style.top="-10000px",L.style.display="table",L.style.top="-"+L.offsetHeight-5+"px",V.style.display="block",setTimeout(function(){y(L,"notie-transition"),L.style.top=0,V.style.opacity="0.75",setTimeout(function(){j=!0},k.animationDelay+10)},20)}b(),S.onclick=function(){l(),n&&setTimeout(function(){n()},k.animationDelay+10)},A.onclick=function(){l(),i&&setTimeout(function(){i()},k.animationDelay+10)},j?(l(),setTimeout(function(){c()},k.animationDelay+10)):c()}function l(){L.style.top="-"+L.offsetHeight-5+"px",V.style.opacity="0",setTimeout(function(){f(L,"notie-transition"),L.style.top="-10000px",V.style.display="none",h(),j=!1},k.animationDelay+10)}function r(e,t,o,i,c,l){k.colorInfo.length>0&&(O.style.backgroundColor=k.colorInfo),k.colorSuccess.length>0&&($.style.backgroundColor=k.colorSuccess),k.colorError.length>0&&(q.style.backgroundColor=k.colorError),k.colorText.length>0&&(F.style.color=k.colorText,G.style.color=k.colorText,J.style.color=k.colorText),g(),"undefined"!=typeof e.type&&e.type?R.setAttribute("type",e.type):R.setAttribute("type","text"),"undefined"!=typeof e.placeholder&&e.placeholder&&R.setAttribute("placeholder",e.placeholder),"undefined"!=typeof e.prefilledValue&&e.prefilledValue?R.value=e.prefilledValue:R.value="",w?n(function(){a(t,o,i,c,l)}):a(t,o,i,c,l)}function a(e,t,o,n,i){function c(){F.innerHTML=e,G.innerHTML=t,J.innerHTML=o,B.style.top="-10000px",B.style.display="table",B.style.top="-"+B.offsetHeight-5+"px",z.style.display="block",setTimeout(function(){y(B,"notie-transition"),B.style.top=0,z.style.opacity="0.75",setTimeout(function(){K=!0,R.focus()},k.animationDelay+10)},20)}b(),$.onclick=function(){d(),n&&setTimeout(function(){n(R.value)},k.animationDelay+10)},q.onclick=function(){d(),i&&setTimeout(function(){i(R.value)},k.animationDelay+10)},K?(d(),setTimeout(function(){c()},k.animationDelay+10)):c()}function d(){B.style.top="-"+B.offsetHeight-5+"px",z.style.opacity="0",setTimeout(function(){f(B,"notie-transition"),z.style.display="none",B.style.top="-10000px",h(),K=!1},k.animationDelay+10)}function s(e,t){k.colorInfo.length>0&&(Q.style.backgroundColor=k.colorInfo),k.colorNeutral.length>0&&(Z.style.backgroundColor=k.colorNeutral),k.colorText.length>0&&(U.style.color=k.colorText,Z.style.color=k.colorText);for(var o=[],i=0;i<arguments.length-2;i++)o[i]=arguments[i+2];if(o.length!==t.length)throw new Error("notie.select number of choices must match number of functions");g(),w?n(function(){u(e,t,o)}):u(e,t,o)}function u(e,t,o){function n(e){U.innerHTML=e,P.style.bottom="-10000px",P.style.display="table",P.style.bottom="-"+P.offsetHeight-5+"px",X.style.display="block",setTimeout(function(){y(P,"notie-transition"),P.style.bottom=0,X.style.opacity="0.75",setTimeout(function(){te=!0},k.animationDelay+10)},20)}b(),document.getElementById("notie-select-choices").innerHTML="";for(var i,c=0;c<t.length;c++){var l=document.createElement("div");if(l.innerHTML=t[c].title,y(l,"notie-select-choice"),Y.appendChild(l),l.style.backgroundColor=window.getComputedStyle(l).backgroundColor,k.colorText.length>0&&(l.style.color=k.colorText),t[c].type)switch(t[c].type){case 1:k.colorSuccess.length>0?l.style.backgroundColor=k.colorSuccess:y(l,"notie-background-success");break;case 2:k.colorWarning.length>0?l.style.backgroundColor=k.colorWarning:y(l,"notie-background-warning");break;case 3:k.colorError.length>0?l.style.backgroundColor=k.colorError:y(l,"notie-background-error");break;case 4:k.colorInfo.length>0?l.style.backgroundColor=k.colorInfo:y(l,"notie-background-info")}else t[c].color&&(l.style.backgroundColor=t[c].color);c>0&&l.style.backgroundColor===i.style.backgroundColor&&(i.style.borderBottom="1px solid rgba(255, 255, 255, 0.2)"),l.onclick=function(e){return function(){p(),setTimeout(function(){o[e]()},k.animationDelay+10)}}(c),i=l}te?(p(),setTimeout(function(){n(e)},k.animationDelay+10)):n(e)}function p(){P.style.bottom="-"+P.offsetHeight-5+"px",X.style.opacity="0",setTimeout(function(){f(P,"notie-transition"),P.style.bottom="-10000px",X.style.display="none",h(),te=!1},k.animationDelay+10)}function m(){return w||j||K||te}function y(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function f(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function g(){document.activeElement&&document.activeElement.blur()}function b(){_=document.body.style.height,ee=document.body.style.overflow,document.body.style.height="100%",document.body.style.overflow="hidden"}function h(){document.body.style.height=_,document.body.style.overflow=ee}var k={colorSuccess:"",colorWarning:"",colorError:"",colorInfo:"",colorNeutral:"",colorText:"",animationDelay:300,backgroundClickDismiss:!0},v=document.createElement("div");v.id="notie-alert-outer",v.onclick=function(){n()},document.body.appendChild(v);var C=document.createElement("div");C.id="notie-alert-inner",v.appendChild(C);var T=document.createElement("div");T.id="notie-alert-content",C.appendChild(T);var x=document.createElement("span");x.id="notie-alert-text",T.appendChild(x);var E,D,w=!1,H=0,L=document.createElement("div");L.id="notie-confirm-outer";var I=document.createElement("div");I.id="notie-confirm-inner",L.appendChild(I);var M=document.createElement("span");M.id="notie-confirm-text",I.appendChild(M);var S=document.createElement("div");S.id="notie-confirm-yes",L.appendChild(S);var A=document.createElement("div");A.id="notie-confirm-no",L.appendChild(A);var N=document.createElement("span");N.id="notie-confirm-text-yes",S.appendChild(N);var W=document.createElement("span");W.id="notie-confirm-text-no",A.appendChild(W);var V=document.createElement("div");V.id="notie-confirm-background",y(V,"notie-transition"),V.onclick=function(){k.backgroundClickDismiss&&l()},document.body.appendChild(L),document.body.appendChild(V);var j=!1,B=document.createElement("div");B.id="notie-input-outer";var z=document.createElement("div");z.id="notie-input-background",y(z,"notie-transition");var O=document.createElement("div");O.id="notie-input-inner",B.appendChild(O);var R=document.createElement("input");R.id="notie-input-field",R.setAttribute("autocomplete","off"),R.setAttribute("autocorrect","off"),R.setAttribute("autocapitalize","off"),R.setAttribute("spellcheck","false"),B.appendChild(R);var $=document.createElement("div");$.id="notie-input-yes",B.appendChild($);var q=document.createElement("div");q.id="notie-input-no",B.appendChild(q);var F=document.createElement("span");F.id="notie-input-text",O.appendChild(F);var G=document.createElement("span");G.id="notie-input-text-yes",$.appendChild(G);var J=document.createElement("span");J.id="notie-input-text-no",q.appendChild(J),document.body.appendChild(B),document.body.appendChild(z),z.onclick=function(){k.backgroundClickDismiss&&d()};var K=!1,P=document.createElement("div");P.id="notie-select-outer";var Q=document.createElement("div");Q.id="notie-select-inner",P.appendChild(Q);var U=document.createElement("span");U.id="notie-select-text",Q.appendChild(U);var X=document.createElement("div");X.id="notie-select-background",y(X,"notie-transition");var Y=document.createElement("div");Y.id="notie-select-choices",P.appendChild(Y);var Z=document.createElement("div");Z.id="notie-select-cancel",Z.innerHTML="Cancel",P.appendChild(Z),document.body.appendChild(P),document.body.appendChild(X),X.onclick=function(){k.backgroundClickDismiss&&p()},Z.onclick=function(){p()};var _,ee,te=!1;return window.addEventListener("keydown",function(e){var t=13===e.which||13===e.keyCode,o=27===e.which||27===e.keyCode;w?(t||o)&&n():j?t?S.click():o&&l():K?t?$.click():o&&d():te&&o&&p()}),{setOptions:e,alert:t,alertHide:n,confirm:i,input:r,select:s,isShowing:m}}();"object"==typeof module&&module.exports&&(module.exports=notie);

@@ -1,33 +0,35 @@

var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var cssnano = require('gulp-cssnano');
var del = require('del');
var gulp = require('gulp')
var sass = require('gulp-sass')
var uglify = require('gulp-uglify')
var rename = require('gulp-rename')
// var cssnano = require('gulp-cssnano')
var del = require('del')
gulp.task('clean', function() {
return del(['./dist']);
});
gulp.task('clean', function () {
return del(['./dist'])
})
gulp.task('script', function() {
gulp.src('./notie.js')
.pipe(gulp.dest('./dist'))
.pipe(uglify())
.pipe(rename('notie.min.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('script', function () {
gulp.src('./src/notie.js')
.pipe(gulp.dest('./dist'))
.pipe(uglify())
.pipe(rename('notie.min.js'))
.pipe(gulp.dest('./dist'))
})
gulp.task('style', function () {
gulp.src(['./notie.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
gulp.src(['./src/notie.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'))
})
gulp.task('default', ['clean'], function() {
gulp.start('script', 'style');
});
gulp.task('default', ['clean'], function () {
gulp.start('script', 'style')
gulp.watch('./src/notie.scss', ['style'])
gulp.watch('./src/notie.js', ['script'])
})
gulp.task('watch', function() {
gulp.watch('./notie.scss', ['style']);
gulp.watch('./notie.js', ['script'])
});
gulp.task('watch', function () {
gulp.watch('./src/notie.scss', ['style'])
gulp.watch('./src/notie.js', ['script'])
})
The MIT License (MIT)
Copyright (c) 2015 Jared Reich
Copyright (c) 2016 Jared Reich

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

@@ -5,4 +5,4 @@ {

"author": "Jared Reich",
"version": "3.2.0",
"main": "notie.js",
"version": "3.3.0",
"main": "./dist/notie.min.js",
"repository": {

@@ -26,2 +26,6 @@ "type": "git",

"del": "^2.2.0",
"eslint": "^3.0.1",
"eslint-config-standard": "^5.3.5",
"eslint-plugin-promise": "^2.0.0",
"eslint-plugin-standard": "^2.0.0",
"gulp": "^3.9.1",

@@ -28,0 +32,0 @@ "gulp-cssnano": "^2.1.1",

# notie
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Join the chat at https://gitter.im/jaredreich/notie](https://badges.gitter.im/jaredreich/notie.svg)](https://gitter.im/jaredreich/notie?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -13,2 +14,3 @@

* Allow user to select choices
* Do other cool stuff

@@ -49,3 +51,3 @@ ![Alt text](/demo.gif?raw=true "Demo")

npm:
```
```bash
npm install notie

@@ -55,3 +57,3 @@ ```

Bower:
```
```bash
bower install notie

@@ -64,3 +66,3 @@ ```

```javascript
notie.alert(alertType(Number), message(String, timeInSeconds);
notie.alert(alertType(Number|String), message(String), timeInSeconds);

@@ -76,6 +78,11 @@ notie.confirm(title(String), yesText(String), noText(String), yesCallback(Function), noCallbackOptional(Function));

notie.alert(1, 'Success!'); // Never hides unless clicked, or escape or enter is pressed
notie.alert('success', 'Success!', 3);
notie.alert(2, 'Warning<br><b>with</b><br><i>HTML</i><br><u>included.</u>', 2); // Hides after 2 seconds
notie.alert('warning', 'Watch it...', 4);
notie.alert(3, 'Error.', 2.5);
notie.alert('error', 'Oops!', 1.5);
notie.alert(4, 'Information.', 3);
notie.alert('info', 'FYI, blah blah blah.', 4);
notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() {

@@ -141,3 +148,9 @@ notie.alert(1, 'Good choice!', 2);

## Other Methods
```javascript
notie.alertHide(optionalCallback) // programmatically hide notie.alert with an optional callback function
notie.isShowing() // true if any element of notie is showing, false otherwise
```
## License
MIT

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