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

angularjs-toast

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angularjs-toast - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

68

angularjs-toast.js
/*!
* @module angularjs-toast
* @description A Simple toast notification service for AngularJS pages
* @version v3.0.0
* @version v3.0.1
* @link https://github.com/sibiraj-s/angularjs-toast#readme

@@ -50,3 +50,3 @@ * @licence MIT License, https://opensource.org/licenses/MIT

$toastFactory = function $toastFactory($rootScope, $http, $templateCache, $compile, $timeout, $toast) {
var cleanupToastContainer, getToastEl, html, options, scope, setNotificationTimer, templateBase, timeoutPromises, toast; // template
var getToastEl, html, htmlTemplate, options, scope, setNotificationTimer, templateBase, timeoutPromises, toast; // template

@@ -67,10 +67,30 @@ templateBase = './angularjs-toast.html';

return document.querySelector('.angularjs-toast');
};
}; // check if templates are present in the body
// append to body
cleanupToastContainer = function cleanupToastContainer() {
if (scope.$toastMessages.length === 0) {
return angular.element(getToastEl()).remove();
}
};
htmlTemplate = angular.element(getToastEl());
if (!htmlTemplate[0]) {
// if the element is not appened to html
// get default template from ->templateBase
// append to ->options.container
$http.get(templateBase, {
cache: $templateCache
}).then(function (response) {
var el, templateElement; // compile the element
// append default template to the ->templateBase
templateElement = $compile(response.data)(scope);
if (angular.isElement(options.container)) {
el = options.container;
} else {
el = document.querySelector(options.container);
}
angular.element(el).append(templateElement);
});
}
timeoutPromises = {}; // remove element besed on time interval ->timeout

@@ -86,4 +106,2 @@

}
cleanupToastContainer();
}, timeout);

@@ -98,3 +116,2 @@ }; // close selected element

scope.$toastMessages.splice(index, 1);
cleanupToastContainer();
}; // toast function

@@ -104,3 +121,3 @@

return toast = function toast(args) {
var dismissible, htmlTemplate, json, message, timeout, toastClass; // user options
var dismissible, json, message, timeout, toastClass; // user options

@@ -114,29 +131,2 @@ message = typeof args === 'string' ? args : args.message;

throw new Error("Toast message is required...");
} // values that bind to HTML
// check if templates are present in the body
// append to body
htmlTemplate = angular.element(getToastEl());
if (!htmlTemplate[0]) {
// if the element is not appened to html
// get default template from ->templateBase
// append to ->options.container
$http.get(templateBase, {
cache: $templateCache
}).then(function (response) {
var el, templateElement; // compile the element
// append default template to the ->templateBase
templateElement = $compile(response.data)(scope);
if (angular.isElement(options.container)) {
el = options.container;
} else {
el = document.querySelector(options.container);
}
angular.element(el).append(templateElement);
});
} // append inputs to json variable

@@ -143,0 +133,0 @@ // this will be pushed to the ->scope.$toastMessages array

/*!
* @module angularjs-toast
* @description A Simple toast notification service for AngularJS pages
* @version v3.0.0
* @version v3.0.1
* @link https://github.com/sibiraj-s/angularjs-toast#readme
* @licence MIT License, https://opensource.org/licenses/MIT
*/
"use strict";(function(){var t,s,$;$=function(){var t;return t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},"".concat((new Date).getTime(),"-").concat(t(),"-").concat(t(),"-").concat(t())},s=function(){var s,a;return a=s={container:"body",defaultToastClass:"alert-success",timeout:5e3,dismissible:!0,maxToast:7,position:"right",containerClass:"",insertFromTop:!0},{configure:function(t){a=angular.extend({},s,t)},$get:function(){return a}}},(t=function(t,o,r,l,a,s){var e,c,u,d,g,m,n;return m="./angularjs-toast.html",r.put(m,'<div class="angularjs-toast" ng-class="::$toastPlace ? \'position-fixed\' : \'position-relative\'"> <ul class="toast-container" ng-class="::[$position, $containerClass]"> <li class="animate-repeat" ng-repeat="data in $toastMessages track by data.id"> <div class="alert alert-dismissible" ng-class="::data.toastClass"> <span ng-bind-html="::data.message"></span> <a href="javascript:void(0)" class="close" data-dismiss="alert" aria-label="close" title="close" ng-click="$close($index, data.id)" ng-if="::data.dismissible" >×</a > </div> </li> </ul></div>'),u=s,(d=t.$new()).$position=u.position,d.$toastPlace="body"===u.container,d.$containerClass=u.containerClass,d.$toastMessages=[],c=function(){return document.querySelector(".angularjs-toast")},e=function(){if(0===d.$toastMessages.length)return angular.element(c()).remove()},n={},g=function(s,t){n[s.id]=a(function(){var t;-1!==(t=d.$toastMessages.indexOf(s))&&d.$toastMessages.splice(t,1),e()},t)},d.$close=function(t,s){a.cancel(n[s]),delete n[s],d.$toastMessages.splice(t,1),e()},function(t){var s,a,e,n,i;if(e="string"==typeof t?t:t.message,n=t.timeout||u.timeout,s=void 0!==t.dismissible?t.dismissible:u.dismissible,i=t.className||u.defaultToastClass,!e)throw new Error("Toast message is required...");angular.element(c())[0]||o.get(m,{cache:r}).then(function(t){var s,a;a=l(t.data)(d),s=angular.isElement(u.container)?u.container:document.querySelector(u.container),angular.element(s).append(a)}),a={message:e,id:$(),toastClass:i,dismissible:s},d.$toastMessages.length===u.maxToast&&(u.insertFromTop?d.$toastMessages.pop():d.$toastMessages.shift()),u.insertFromTop?d.$toastMessages.unshift(a):d.$toastMessages.push(a),g(a,n)}}).$inject=["$rootScope","$http","$templateCache","$compile","$timeout","$toast"],angular.module("angularjsToast",["ngSanitize","ngAnimate"]).provider("$toast",s).factory("toast",t)}).call(void 0);
"use strict";(function(){var s,t,g;g=function(){var s;return s=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},"".concat((new Date).getTime(),"-").concat(s(),"-").concat(s(),"-").concat(s())},t=function(){var t,a;return a=t={container:"body",defaultToastClass:"alert-success",timeout:5e3,dismissible:!0,maxToast:7,position:"right",containerClass:"",insertFromTop:!0},{configure:function(s){a=angular.extend({},t,s)},$get:function(){return a}}},(s=function(s,t,a,e,n,i){var o,r,l,c,u,d;return u="./angularjs-toast.html",a.put(u,'<div class="angularjs-toast" ng-class="::$toastPlace ? \'position-fixed\' : \'position-relative\'"> <ul class="toast-container" ng-class="::[$position, $containerClass]"> <li class="animate-repeat" ng-repeat="data in $toastMessages track by data.id"> <div class="alert alert-dismissible" ng-class="::data.toastClass"> <span ng-bind-html="::data.message"></span> <a href="javascript:void(0)" class="close" data-dismiss="alert" aria-label="close" title="close" ng-click="$close($index, data.id)" ng-if="::data.dismissible" >×</a > </div> </li> </ul></div>'),r=i,(l=s.$new()).$position=r.position,l.$toastPlace="body"===r.container,l.$containerClass=r.containerClass,l.$toastMessages=[],o=function(){return document.querySelector(".angularjs-toast")},angular.element(o())[0]||t.get(u,{cache:a}).then(function(s){var t,a;a=e(s.data)(l),t=angular.isElement(r.container)?r.container:document.querySelector(r.container),angular.element(t).append(a)}),d={},c=function(t,s){d[t.id]=n(function(){var s;-1!==(s=l.$toastMessages.indexOf(t))&&l.$toastMessages.splice(s,1)},s)},l.$close=function(s,t){n.cancel(d[t]),delete d[t],l.$toastMessages.splice(s,1)},function(s){var t,a,e,n,i;if(e="string"==typeof s?s:s.message,n=s.timeout||r.timeout,t=void 0!==s.dismissible?s.dismissible:r.dismissible,i=s.className||r.defaultToastClass,!e)throw new Error("Toast message is required...");a={message:e,id:g(),toastClass:i,dismissible:t},l.$toastMessages.length===r.maxToast&&(r.insertFromTop?l.$toastMessages.pop():l.$toastMessages.shift()),r.insertFromTop?l.$toastMessages.unshift(a):l.$toastMessages.push(a),c(a,n)}}).$inject=["$rootScope","$http","$templateCache","$compile","$timeout","$toast"],angular.module("angularjsToast",["ngSanitize","ngAnimate"]).provider("$toast",t).factory("toast",s)}).call(void 0);
//# sourceMappingURL=angularjs-toast.min.js.map

@@ -16,2 +16,8 @@ # CHANGELOG

## v3.0.1 (2020-01-02)
#### Enhancements
- render notification template on app load ([f9c057f](https://github.com/sibiraj-s/angularjs-toast/commit/f9c057f))
## v3.0.0 (2020-01-01)

@@ -18,0 +24,0 @@

{
"name": "angularjs-toast",
"version": "3.0.0",
"version": "3.0.1",
"description": "A Simple toast notification service for AngularJS pages",

@@ -5,0 +5,0 @@ "author": "sibiraj-s",

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