Comparing version 2.1.2 to 2.1.4
@@ -1,2 +0,2 @@ | ||
!function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=u(t)),v)}function i(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function o(e){w=e}function s(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var i=m();v||n(i),l(e,i,t)||d(i)}function c(t){var i=m();return v||n(i),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function d(t){for(var n=v.children(),i=n.length-1;i>=0;i--)l(e(n[i]),t)}function l(t,n,i){var o=i&&i.force?i.force:!1;return t&&(o||0===e(":focus",t).length)?(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0):!1}function u(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass).attr("aria-live","polite").attr("role","alert"),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">×</button>',newestOnTop:!0,preventDuplicates:!1,progressBar:!1}}function f(e){w&&w(e)}function g(t){function i(e){return null==e&&(e=""),new String(e).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function o(){r(),d(),l(),u(),p(),c()}function s(){y.hover(b,O),!x.onclick&&x.tapToDismiss&&y.click(w),x.closeButton&&k&&k.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),w(!0)}),x.onclick&&y.click(function(e){x.onclick(e),w()})}function a(){y.hide(),y[x.showMethod]({duration:x.showDuration,easing:x.showEasing,complete:x.onShown}),x.timeOut>0&&(H=setTimeout(w,x.timeOut),q.maxHideTime=parseFloat(x.timeOut),q.hideEta=(new Date).getTime()+q.maxHideTime,x.progressBar&&(q.intervalId=setInterval(D,10)))}function r(){t.iconClass&&y.addClass(x.toastClass).addClass(E)}function c(){x.newestOnTop?v.prepend(y):v.append(y)}function d(){t.title&&(I.append(x.escapeHtml?i(t.title):t.title).addClass(x.titleClass),y.append(I))}function l(){t.message&&(M.append(x.escapeHtml?i(t.message):t.message).addClass(x.messageClass),y.append(M))}function u(){x.closeButton&&(k.addClass("toast-close-button").attr("role","button"),y.prepend(k))}function p(){x.progressBar&&(B.addClass("toast-progress"),y.prepend(B))}function g(e,t){if(e.preventDuplicates){if(t.message===C)return!0;C=t.message}return!1}function w(t){var n=t&&x.closeMethod!==!1?x.closeMethod:x.hideMethod,i=t&&x.closeDuration!==!1?x.closeDuration:x.hideDuration,o=t&&x.closeEasing!==!1?x.closeEasing:x.hideEasing;return!e(":focus",y).length||t?(clearTimeout(q.intervalId),y[n]({duration:i,easing:o,complete:function(){h(y),x.onHidden&&"hidden"!==j.state&&x.onHidden(),j.state="hidden",j.endTime=new Date,f(j)}})):void 0}function O(){(x.timeOut>0||x.extendedTimeOut>0)&&(H=setTimeout(w,x.extendedTimeOut),q.maxHideTime=parseFloat(x.extendedTimeOut),q.hideEta=(new Date).getTime()+q.maxHideTime)}function b(){clearTimeout(H),q.hideEta=0,y.stop(!0,!0)[x.showMethod]({duration:x.showDuration,easing:x.showEasing})}function D(){var e=(q.hideEta-(new Date).getTime())/q.maxHideTime*100;B.width(e+"%")}var x=m(),E=t.iconClass||x.iconClass;if("undefined"!=typeof t.optionsOverride&&(x=e.extend(x,t.optionsOverride),E=t.optionsOverride.iconClass||E),!g(x,t)){T++,v=n(x,!0);var H=null,y=e("<div/>"),I=e("<div/>"),M=e("<div/>"),B=e("<div/>"),k=e(x.closeHtml),q={intervalId:null,hideEta:null,maxHideTime:null},j={toastId:T,state:"visible",startTime:new Date,options:x,map:t};return o(),a(),s(),f(j),x.debug&&console&&console.log(j),y}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),C=void 0))}var v,w,C,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:i,options:{},subscribe:o,success:s,version:"2.1.2",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)}); | ||
//# sourceMappingURL=toastr.js.map | ||
!function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=d(t)),v)}function o(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function s(e){C=e}function i(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var o=m();v||n(o),u(e,o,t)||l(o)}function c(t){var o=m();return v||n(o),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function l(t){for(var n=v.children(),o=n.length-1;o>=0;o--)u(e(n[o]),t)}function u(t,n,o){var s=!(!o||!o.force)&&o.force;return!(!t||!s&&0!==e(":focus",t).length)&&(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0)}function d(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">×</button>',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1}}function f(e){C&&C(e)}function g(t){function o(e){return null==e&&(e=""),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function s(){c(),u(),d(),p(),g(),C(),l(),i()}function i(){var e="";switch(t.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}I.attr("aria-live",e)}function a(){E.closeOnHover&&I.hover(H,D),!E.onclick&&E.tapToDismiss&&I.click(b),E.closeButton&&j&&j.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),E.onCloseClick&&E.onCloseClick(e),b(!0)}),E.onclick&&I.click(function(e){E.onclick(e),b()})}function r(){I.hide(),I[E.showMethod]({duration:E.showDuration,easing:E.showEasing,complete:E.onShown}),E.timeOut>0&&(k=setTimeout(b,E.timeOut),F.maxHideTime=parseFloat(E.timeOut),F.hideEta=(new Date).getTime()+F.maxHideTime,E.progressBar&&(F.intervalId=setInterval(x,10)))}function c(){t.iconClass&&I.addClass(E.toastClass).addClass(y)}function l(){E.newestOnTop?v.prepend(I):v.append(I)}function u(){if(t.title){var e=t.title;E.escapeHtml&&(e=o(t.title)),M.append(e).addClass(E.titleClass),I.append(M)}}function d(){if(t.message){var e=t.message;E.escapeHtml&&(e=o(t.message)),B.append(e).addClass(E.messageClass),I.append(B)}}function p(){E.closeButton&&(j.addClass(E.closeClass).attr("role","button"),I.prepend(j))}function g(){E.progressBar&&(q.addClass(E.progressClass),I.prepend(q))}function C(){E.rtl&&I.addClass("rtl")}function O(e,t){if(e.preventDuplicates){if(t.message===w)return!0;w=t.message}return!1}function b(t){var n=t&&E.closeMethod!==!1?E.closeMethod:E.hideMethod,o=t&&E.closeDuration!==!1?E.closeDuration:E.hideDuration,s=t&&E.closeEasing!==!1?E.closeEasing:E.hideEasing;if(!e(":focus",I).length||t)return clearTimeout(F.intervalId),I[n]({duration:o,easing:s,complete:function(){h(I),clearTimeout(k),E.onHidden&&"hidden"!==P.state&&E.onHidden(),P.state="hidden",P.endTime=new Date,f(P)}})}function D(){(E.timeOut>0||E.extendedTimeOut>0)&&(k=setTimeout(b,E.extendedTimeOut),F.maxHideTime=parseFloat(E.extendedTimeOut),F.hideEta=(new Date).getTime()+F.maxHideTime)}function H(){clearTimeout(k),F.hideEta=0,I.stop(!0,!0)[E.showMethod]({duration:E.showDuration,easing:E.showEasing})}function x(){var e=(F.hideEta-(new Date).getTime())/F.maxHideTime*100;q.width(e+"%")}var E=m(),y=t.iconClass||E.iconClass;if("undefined"!=typeof t.optionsOverride&&(E=e.extend(E,t.optionsOverride),y=t.optionsOverride.iconClass||y),!O(E,t)){T++,v=n(E,!0);var k=null,I=e("<div/>"),M=e("<div/>"),B=e("<div/>"),q=e("<div/>"),j=e(E.closeHtml),F={intervalId:null,hideEta:null,maxHideTime:null},P={toastId:T,state:"visible",startTime:new Date,options:E,map:t};return s(),r(),a(),f(P),E.debug&&console&&console.log(P),I}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),w=void 0))}var v,C,w,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:o,options:{},subscribe:s,success:i,version:"2.1.4",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)}); | ||
//# sourceMappingURL=toastr.js.map |
@@ -0,1 +1,18 @@ | ||
# 2.1.4 (2017-12-07) | ||
- Same as 2.1.3, except 2.1.4 is on NPM | ||
# 2.1.3 (2016-07-22) | ||
## New Features | ||
- Right to left text support | ||
- Added callbacks for click events on close button | ||
## Bug Fixes | ||
- Fixed some CSS that prevented touch events from propagating on iOS devices | ||
- Removed role attribute because it duplicated voice over on text-to-speech readers; kept aria-live. | ||
- Consistent line-heights for close button to resolve issues with Bootstrap. | ||
## Dev Ops | ||
- Removed Plato from gulp | ||
# 2.1.2 (2015-08-06) | ||
@@ -2,0 +19,0 @@ |
/* jshint node:true, camelcase:false */ | ||
var gulp = require('gulp'); | ||
var del = require('del'); | ||
var glob = require('glob'); | ||
var karma = require('karma').server; | ||
var merge = require('merge-stream'); | ||
var plato = require('plato'); | ||
var plug = require('gulp-load-plugins')(); | ||
@@ -17,3 +14,2 @@ | ||
var colors = plug.util.colors; | ||
var log = plug.util.log; | ||
@@ -30,4 +26,4 @@ | ||
*/ | ||
gulp.task('analyze', function() { | ||
log('Analyzing source with JSHint, JSCS, and Plato'); | ||
gulp.task('analyze', function () { | ||
log('Analyzing source with JSHint and JSCS'); | ||
@@ -37,4 +33,2 @@ var jshint = analyzejshint([paths.js]); | ||
startPlatoVisualizer(); | ||
return merge(jshint, jscs); | ||
@@ -47,3 +41,3 @@ }); | ||
*/ | ||
gulp.task('js', function() { | ||
gulp.task('js', function () { | ||
log('Bundling, minifying, and copying the app\'s JavaScript'); | ||
@@ -58,3 +52,3 @@ | ||
.pipe(plug.sourcemaps.write('.')) | ||
.pipe(plug.rename(function(path) { | ||
.pipe(plug.rename(function (path) { | ||
if (path.extname === '.js') { | ||
@@ -71,3 +65,3 @@ path.basename += '.min'; | ||
*/ | ||
gulp.task('css', function() { | ||
gulp.task('css', function () { | ||
log('Bundling, minifying, and copying the app\'s CSS'); | ||
@@ -77,3 +71,2 @@ | ||
.pipe(plug.less()) | ||
// .pipe(plug.autoprefixer('last 2 version', '> 5%')) | ||
.pipe(gulp.dest(paths.build)) | ||
@@ -90,3 +83,3 @@ .pipe(plug.bytediff.start()) | ||
*/ | ||
gulp.task('default', ['js', 'css'], function() { | ||
gulp.task('default', ['js', 'css'], function () { | ||
log('Analyze, Build CSS and JS'); | ||
@@ -101,3 +94,3 @@ }); | ||
*/ | ||
gulp.task('clean', function(cb) { | ||
gulp.task('clean', function (cb) { | ||
log('Cleaning: ' + plug.util.colors.blue(paths.report)); | ||
@@ -116,4 +109,4 @@ log('Cleaning: ' + plug.util.colors.blue(paths.build)); | ||
*/ | ||
gulp.task('test', function(done) { | ||
startTests(true /*singleRun*/ , done); | ||
gulp.task('test', function (done) { | ||
startTests(true /*singleRun*/, done); | ||
}); | ||
@@ -151,23 +144,2 @@ | ||
/** | ||
* Start Plato inspector and visualizer | ||
*/ | ||
function startPlatoVisualizer() { | ||
log('Running Plato'); | ||
var files = glob.sync('toastr.js'); | ||
var options = { | ||
title: 'Plato Inspections Report' | ||
}; | ||
var outputDir = './report/plato'; | ||
plato.inspect(files, outputDir, options, platoCompleted); | ||
function platoCompleted(report) { | ||
var overview = plato.getOverviewReport(report); | ||
log(overview.summary); | ||
} | ||
} | ||
/** | ||
* Start the tests using karma. | ||
@@ -174,0 +146,0 @@ * @param {boolean} singleRun - True means run once and end (CI), or keep running (dev) |
// Karma configuration | ||
// Generated on Thu Sep 04 2014 07:41:43 GMT-0400 (EDT) | ||
module.exports = function(config) { | ||
config.set({ | ||
module.exports = function (config) { | ||
config.set({ | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['qunit'], | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['qunit'], | ||
// plugins: ['karma-qunit', 'karma-coverage', 'phantomjs', 'karma-phantomjs-launcher'], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'node_modules/jquery/dist/jquery.min.js', | ||
'build/toastr.css', | ||
'toastr.js', | ||
'node_modules/qunitjs/qunit/qunit.js', | ||
'tests/unit/qunit-helper.js', | ||
'tests/unit/toastr-tests.js' | ||
], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
// 'http://code.jquery.com/jquery.js', | ||
'node_modules/jquery/dist/jquery.min.js', | ||
'build/toastr.css', | ||
'toastr.js', | ||
'node_modules/qunitjs/qunit/qunit.js', | ||
'tests/unit/qunit-helper.js', | ||
//'tests/unit/x.js' | ||
'tests/unit/toastr-tests.js' | ||
], | ||
// list of files to exclude | ||
exclude: [], | ||
// list of files to exclude | ||
exclude: [ | ||
], | ||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'toastr.js': 'coverage' | ||
}, | ||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'toastr.js': 'coverage' | ||
}, | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress', 'coverage'], | ||
coverageReporter: { | ||
type: 'lcov', | ||
dir: 'tests/coverage' | ||
}, | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress', 'coverage'], | ||
// web server port | ||
port: 9876, | ||
coverageReporter: { | ||
type: 'lcov', | ||
dir: 'tests/coverage' | ||
}, | ||
// web server port | ||
port: 9876, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true | ||
}); | ||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true | ||
}); | ||
}; |
@@ -6,3 +6,3 @@ { | ||
"style": "build/toastr.min.css", | ||
"version": "2.1.2", | ||
"version": "2.1.4", | ||
"description": "ToastrJS is a JavaScript library for Gnome / Growl type non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.", | ||
@@ -38,5 +38,6 @@ "homepage": "http://www.toastrjs.com", | ||
], | ||
"dependencies": { | ||
"jquery": ">=1.12.0" | ||
}, | ||
"devDependencies": { | ||
"del": "^0.1.3", | ||
"glob": "^4.0.6", | ||
"gulp": "^3.8.10", | ||
@@ -43,0 +44,0 @@ "gulp-bytediff": "^0.2.0", |
@@ -5,5 +5,6 @@ # toastr | ||
[![Build Status](https://travis-ci.org/CodeSeven/toastr.svg)](https://travis-ci.org/CodeSeven/toastr) | ||
Browser testing provided by BrowserStack. | ||
## Current Version | ||
2.1.2 | ||
2.1.4 | ||
@@ -18,9 +19,8 @@ ## Demo | ||
#### Debug | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.js](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.js) | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css) | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css) | ||
#### Minified | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js) | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css) | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js) | ||
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css) | ||
## Install | ||
@@ -43,2 +43,24 @@ | ||
#### [Ruby on Rails](https://github.com/tylergannon/toastr-rails) | ||
```ruby | ||
# Gemfile | ||
gem 'toastr-rails' | ||
``` | ||
```coffee | ||
# application.coffee | ||
#= require toastr | ||
``` | ||
```scss | ||
// application.scss | ||
@import "toastr"; | ||
``` | ||
## Wiki and Change Log | ||
@@ -48,6 +70,6 @@ [Wiki including Change Log](https://github.com/CodeSeven/toastr/wiki) | ||
## Breaking Changes | ||
####Animation Changes | ||
#### Animation Changes | ||
The following animations options have been deprecated and should be replaced: | ||
- Replace `options.fadeIn` with `options.showDuration` | ||
@@ -95,3 +117,3 @@ - Replace `options.onFadeIn` with `options.onShown` | ||
### Escape HTML characters | ||
In case you want to escape HTML charaters in title and message | ||
In case you want to escape HTML characters in title and message | ||
@@ -106,3 +128,3 @@ toastr.options.escapeHtml = true; | ||
Optionally override the close button's HTML. | ||
Optionally override the close button's HTML. | ||
@@ -130,5 +152,7 @@ ```js | ||
```js | ||
// Define a callback for when the toast is shown/hidden | ||
// Define a callback for when the toast is shown/hidden/clicked | ||
toastr.options.onShown = function() { console.log('hello'); } | ||
toastr.options.onHidden = function() { console.log('goodbye'); } | ||
toastr.options.onclick = function() { console.log('clicked'); } | ||
toastr.options.onCloseClick = function() { console.log('close button clicked'); } | ||
``` | ||
@@ -139,3 +163,3 @@ | ||
####Easings | ||
#### Easings | ||
Optionally override the animation easing to show or hide the toasts. Default is swing. swing and linear are built into jQuery. | ||
@@ -155,3 +179,3 @@ ```js | ||
####Animation Method | ||
#### Animation Method | ||
Use the jQuery show/hide method of your choice. These default to fadeIn/fadeOut. The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. | ||
@@ -163,4 +187,4 @@ ```js | ||
``` | ||
###Prevent Duplicates | ||
### Prevent Duplicates | ||
Rather than having identical toasts stack, set the preventDuplicates property to true. Duplicates are matched to the previous toast based on their message content. | ||
@@ -171,3 +195,3 @@ ```js | ||
###Timeouts | ||
### Timeouts | ||
Control how toastr interacts with users by setting timeouts appropriately. Timeouts can be disabled by setting them to 0. | ||
@@ -178,5 +202,5 @@ ```js | ||
``` | ||
###Progress Bar | ||
### Progress Bar | ||
Visually indicate how long before a toast expires. | ||
@@ -187,2 +211,8 @@ ```js | ||
### rtl | ||
Flip the toastr to be displayed properly for right-to-left languages. | ||
```js | ||
toastr.options.rtl = true; | ||
``` | ||
## Building Toastr | ||
@@ -189,0 +219,0 @@ |
@@ -19,3 +19,3 @@ /// <reference path="../../../toastr.js" /> | ||
var sampleMsg = 'I don\'t think they really exist'; | ||
var sampleTitle = 'ROUS'; | ||
var sampleTitle = 'TEST'; | ||
var selectors = { | ||
@@ -54,4 +54,2 @@ container: 'div#toast-container', | ||
setTimeout(function () { | ||
//debugger; | ||
//console.log($container.children().length); | ||
ok($container && $container.children().length === 2); | ||
@@ -145,2 +143,28 @@ //Teardown | ||
}); | ||
asyncTest('clear and show - clear toast after hover', 1, function () { | ||
//Arrange | ||
var $toast = toastr.info(sampleMsg, sampleTitle); | ||
var $container = toastr.getContainer(); | ||
$toast.trigger("mouseout"); | ||
//Act | ||
setTimeout(function () { | ||
//Assert | ||
ok($container.find('div.toast-title').length === 0, 'Toast clears after a mouse hover'); //Teardown | ||
resetContainer(); | ||
start(); | ||
}, 500); | ||
}); | ||
asyncTest('clear and show - do not clear toast after hover', 1, function () { | ||
//Arrange | ||
var $toast = toastr.info(sampleMsg, sampleTitle, { closeOnHover: false }); | ||
var $container = toastr.getContainer(); | ||
$toast.trigger("mouseout"); | ||
//Act | ||
setTimeout(function () { | ||
//Assert | ||
ok($container.find('div.toast-title').length === 1, 'Toast does not clear after a mouse hover'); //Teardown | ||
resetContainer(); | ||
start(); | ||
}, 500); | ||
}); | ||
test('clear and show - after clear all toasts new toast still appears', 1, function () { | ||
@@ -445,3 +469,94 @@ //Arrange | ||
module('event'); | ||
module('rtl', { | ||
teardown: function () { | ||
toastr.options.rtl = false; | ||
} | ||
}); | ||
test('toastr is ltr by default', 1, function () { | ||
//Arrange | ||
//Act | ||
//Assert | ||
toastr.subscribe(function(response) { | ||
equal(response.options.rtl, false, 'ltr by default (i.e. rtl=false)'); | ||
}); | ||
var $toast = toastr.success(''); | ||
//Teardown | ||
toastr.subscribe(null); | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
test('ltr toastr does not have .rtl class', 1, function () { | ||
//Arrange | ||
//Act | ||
var $toast = toastr.success(''); | ||
//Assert | ||
ok($toast.hasClass('rtl') === false, 'ltr div container does not have .rtl class'); | ||
//Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
test('rtl toastr has .rtl class', 1, function () { | ||
//Arrange | ||
toastr.options.rtl = true; | ||
//Act | ||
var $toast = toastr.success(''); | ||
//Assert | ||
ok($toast.hasClass('rtl'), 'rtl div container has .rtl class'); | ||
//Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
module('accessibility'); | ||
test('toastr success has aria polite',1,function() { | ||
// Arrange | ||
var $toast = toastr.success(''); | ||
// Act | ||
ok($toast.attr('aria-live')==='polite', 'success toast has aria-live of polite'); | ||
// Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
test('toastr info has aria polite',1,function() { | ||
// Arrange | ||
var $toast = toastr.info(''); | ||
// Act | ||
ok($toast.attr('aria-live')==='polite', 'info toast has aria-live of polite'); | ||
// Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
test('toastr warning has aria assertive',1,function() { | ||
// Arrange | ||
var $toast = toastr.warning(''); | ||
// Act | ||
ok($toast.attr('aria-live')==='assertive', 'warning toast has aria-live of assertive'); | ||
// Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
test('toastr error has aria assertive',1,function() { | ||
// Arrange | ||
var $toast = toastr.error(''); | ||
// Act | ||
ok($toast.attr('aria-live')==='assertive', 'error toast has aria-live of assertive'); | ||
// Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
}); | ||
module('event', { | ||
teardown: function () { | ||
toastr.options.closeButton = false; | ||
toastr.options.hideDuration = 0; | ||
} | ||
}); | ||
asyncTest('event - onShown is executed', 1, function () { | ||
@@ -503,2 +618,23 @@ // Arrange | ||
asyncTest('event - onCloseClick is executed', 1, function () { | ||
//Arrange | ||
var run = false; | ||
toastr.options.closeButton = true; | ||
toastr.options.closeDuration = 0; | ||
toastr.options.hideDuration = 2000; | ||
var onCloseClick = function () { run = true; }; | ||
toastr.options.onCloseClick = onCloseClick; | ||
toastr.options.timeOut = 1; | ||
//Act | ||
var $toast = toastr.success(sampleMsg, sampleTitle); | ||
$toast.find('button.toast-close-button').click(); | ||
setTimeout(function () { | ||
// Assert | ||
ok(run); //Teardown | ||
$toast.remove(); | ||
clearContainerChildren(); | ||
start(); | ||
}, delay); | ||
}); | ||
test('event - message appears when no show or hide method functions provided', 1, function () { | ||
@@ -575,2 +711,29 @@ //Arrange | ||
module('subscription'); | ||
asyncTest('subscribe - triggers 2 visible and 2 hidden response notifications while clicking on a toast', 1, function () { | ||
//Arrange | ||
var $toast = []; | ||
var expectedReponses = []; | ||
//Act | ||
toastr.subscribe(function(response) { | ||
if(response.options.testId) { | ||
expectedReponses.push(response); | ||
} | ||
}) | ||
$toast[0] = toastr.info(sampleMsg, sampleTitle, {testId : 1}); | ||
$toast[1] = toastr.info(sampleMsg, sampleTitle, {testId : 2}); | ||
$toast[1].click() | ||
setTimeout(function () { | ||
// Assert | ||
ok(expectedReponses.length === 4); | ||
//Teardown | ||
clearContainerChildren(); | ||
toastr.subscribe(null); | ||
start(); | ||
}, delay); | ||
}); | ||
module('order of appearance'); | ||
@@ -577,0 +740,0 @@ test('Newest toast on top', 1, function () { |
@@ -14,3 +14,3 @@ /* | ||
/* global define */ | ||
; (function (define) { | ||
(function (define) { | ||
define(['jquery'], function ($) { | ||
@@ -37,3 +37,3 @@ return (function () { | ||
success: success, | ||
version: '2.1.2', | ||
version: '2.1.4', | ||
warning: warning | ||
@@ -149,5 +149,3 @@ }; | ||
.attr('id', options.containerId) | ||
.addClass(options.positionClass) | ||
.attr('aria-live', 'polite') | ||
.attr('role', 'alert'); | ||
.addClass(options.positionClass); | ||
@@ -176,2 +174,3 @@ $container.appendTo($(options.target)); | ||
closeEasing: false, | ||
closeOnHover: true, | ||
@@ -193,5 +192,8 @@ extendedTimeOut: 1000, | ||
closeHtml: '<button type="button">×</button>', | ||
closeClass: 'toast-close-button', | ||
newestOnTop: true, | ||
preventDuplicates: false, | ||
progressBar: false | ||
progressBar: false, | ||
progressClass: 'toast-progress', | ||
rtl: false | ||
}; | ||
@@ -254,6 +256,7 @@ } | ||
function escapeHtml(source) { | ||
if (source == null) | ||
source = ""; | ||
if (source == null) { | ||
source = ''; | ||
} | ||
return new String(source) | ||
return source | ||
.replace(/&/g, '&') | ||
@@ -272,7 +275,25 @@ .replace(/"/g, '"') | ||
setProgressBar(); | ||
setRTL(); | ||
setSequence(); | ||
setAria(); | ||
} | ||
function setAria() { | ||
var ariaValue = ''; | ||
switch (map.iconClass) { | ||
case 'toast-success': | ||
case 'toast-info': | ||
ariaValue = 'polite'; | ||
break; | ||
default: | ||
ariaValue = 'assertive'; | ||
} | ||
$toastElement.attr('aria-live', ariaValue); | ||
} | ||
function handleEvents() { | ||
$toastElement.hover(stickAround, delayedHideToast); | ||
if (options.closeOnHover) { | ||
$toastElement.hover(stickAround, delayedHideToast); | ||
} | ||
if (!options.onclick && options.tapToDismiss) { | ||
@@ -289,2 +310,7 @@ $toastElement.click(hideToast); | ||
} | ||
if (options.onCloseClick) { | ||
options.onCloseClick(event); | ||
} | ||
hideToast(true); | ||
@@ -335,3 +361,7 @@ }); | ||
if (map.title) { | ||
$titleElement.append(!options.escapeHtml ? map.title : escapeHtml(map.title)).addClass(options.titleClass); | ||
var suffix = map.title; | ||
if (options.escapeHtml) { | ||
suffix = escapeHtml(map.title); | ||
} | ||
$titleElement.append(suffix).addClass(options.titleClass); | ||
$toastElement.append($titleElement); | ||
@@ -343,3 +373,7 @@ } | ||
if (map.message) { | ||
$messageElement.append(!options.escapeHtml ? map.message : escapeHtml(map.message)).addClass(options.messageClass); | ||
var suffix = map.message; | ||
if (options.escapeHtml) { | ||
suffix = escapeHtml(map.message); | ||
} | ||
$messageElement.append(suffix).addClass(options.messageClass); | ||
$toastElement.append($messageElement); | ||
@@ -351,3 +385,3 @@ } | ||
if (options.closeButton) { | ||
$closeElement.addClass('toast-close-button').attr('role', 'button'); | ||
$closeElement.addClass(options.closeClass).attr('role', 'button'); | ||
$toastElement.prepend($closeElement); | ||
@@ -359,3 +393,3 @@ } | ||
if (options.progressBar) { | ||
$progressElement.addClass('toast-progress'); | ||
$progressElement.addClass(options.progressClass); | ||
$toastElement.prepend($progressElement); | ||
@@ -365,2 +399,8 @@ } | ||
function setRTL() { | ||
if (options.rtl) { | ||
$toastElement.addClass('rtl'); | ||
} | ||
} | ||
function shouldExit(options, map) { | ||
@@ -391,2 +431,3 @@ if (options.preventDuplicates) { | ||
removeToast($toastElement); | ||
clearTimeout(intervalId); | ||
if (options.onHidden && response.state !== 'hidden') { | ||
@@ -393,0 +434,0 @@ options.onHidden(); |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
23
3
251
842880
1
75
12016
+ Addedjquery@>=1.12.0
+ Addedjquery@3.7.1(transitive)