mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add Toastr definitions and tests
This commit is contained in:
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for Toastr 1.0
|
||||
// Project: https://github.com/CodeSeven/toastr
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface ToastOptions {
|
||||
tapToDismiss?: bool;
|
||||
toastClass?: string;
|
||||
containerId?: string;
|
||||
debug?: bool;
|
||||
fadeIn?: number;
|
||||
fadeOut?: number;
|
||||
extendedTimeOut?: number;
|
||||
iconClasses?: {
|
||||
error: string;
|
||||
info: string;
|
||||
success: string;
|
||||
warning: string;
|
||||
};
|
||||
iconClass?: string;
|
||||
positionClass?: string;
|
||||
timeOut?: number;
|
||||
titleClass?: string;
|
||||
messageClass?: string;
|
||||
}
|
||||
|
||||
interface Toastr {
|
||||
options: ToastOptions;
|
||||
|
||||
info(message: string, title?: string);
|
||||
warning(message: string, title?: string);
|
||||
success(message: string, title?: string);
|
||||
error(message: string, title?: string);
|
||||
}
|
||||
|
||||
declare var toastr: Toastr;
|
||||
@@ -1,63 +1,64 @@
|
||||
DefinitelyTyped
|
||||
===============
|
||||
|
||||
TypeScript type definitions repository for popular JavaScript libraries.
|
||||
|
||||
The project aims to provide *high quality* definitions for the most popular libraries out there.
|
||||
|
||||
Complete
|
||||
--------
|
||||
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
|
||||
* [async](https://github.com/caolan/async)
|
||||
* [Backbone.js](http://backbonejs.org/)
|
||||
* [Bootstrap](http://twitter.github.com/bootstrap/)
|
||||
* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [Chosen](http://harvesthq.github.com/chosen/)
|
||||
* [dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [ember.js](http://emberjs.com/)
|
||||
* [Express](http://expressjs.com/)
|
||||
* [Fancybox](http://fancybox.net/)
|
||||
* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper))
|
||||
* [Handlebars](http://handlebarsjs.com/)
|
||||
* [History.js](https://github.com/balupton/History.js/)
|
||||
* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac))
|
||||
* [Impress.js](https://github.com/bartaz/impress.js)
|
||||
* [Jasmine](http://pivotal.github.com/jasmine/)
|
||||
* [jQuery.Globalize](https://github.com/jquery/globalize)
|
||||
* [jQuery](http://jquery.com/) (from TypeScript samples)
|
||||
* [jQuery Mobile](http://jquerymobile.com)
|
||||
* [jQuery UI](http://jqueryui.com/)
|
||||
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
|
||||
* [Knockout.js](http://knockoutjs.com/)
|
||||
* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping)
|
||||
* [linq.js](http://linqjs.codeplex.com/) (by Marcin Najder (https://github.com/marcinnajder))
|
||||
* [Modernizr](http://modernizr.com/)
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
* [Mustache.js](https://github.com/janl/mustache.js)
|
||||
* [Node.js](http://nodejs.org/) (from TypeScript samples)
|
||||
* [node_redis](https://github.com/mranney/node_redis)
|
||||
* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver)
|
||||
* [PhoneGap](http://phonegap.com)
|
||||
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall))
|
||||
* [Sammy.js](http://sammyjs.org/)
|
||||
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Spin](http://fgnass.github.com/spin.js/)
|
||||
* [Sugar](http://sugarjs.com/) (by Josh Baldwin)(https://github.com/jbaldwin/)
|
||||
* [Teechart](http://www.steema.com) (by [Steema]) (http://www.steema.com)
|
||||
* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Underscore.js](http://underscorejs.org/)
|
||||
* [Underscore.js (Typed)](http://underscorejs.org/) (by Josh Baldwin)(https://github.com/jbaldwin/)
|
||||
|
||||
Next
|
||||
----
|
||||
* Facebook SDK
|
||||
* jQuery.Validate
|
||||
* google.visualization
|
||||
* Meteor
|
||||
* Isotope
|
||||
* Zepto
|
||||
* Socket.IO
|
||||
DefinitelyTyped
|
||||
===============
|
||||
|
||||
TypeScript type definitions repository for popular JavaScript libraries.
|
||||
|
||||
The project aims to provide *high quality* definitions for the most popular libraries out there.
|
||||
|
||||
Complete
|
||||
--------
|
||||
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
|
||||
* [async](https://github.com/caolan/async)
|
||||
* [Backbone.js](http://backbonejs.org/)
|
||||
* [Bootstrap](http://twitter.github.com/bootstrap/)
|
||||
* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [Chosen](http://harvesthq.github.com/chosen/)
|
||||
* [dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [ember.js](http://emberjs.com/)
|
||||
* [Express](http://expressjs.com/)
|
||||
* [Fancybox](http://fancybox.net/)
|
||||
* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper))
|
||||
* [Handlebars](http://handlebarsjs.com/)
|
||||
* [History.js](https://github.com/balupton/History.js/)
|
||||
* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac))
|
||||
* [Impress.js](https://github.com/bartaz/impress.js)
|
||||
* [Jasmine](http://pivotal.github.com/jasmine/)
|
||||
* [jQuery.Globalize](https://github.com/jquery/globalize)
|
||||
* [jQuery](http://jquery.com/) (from TypeScript samples)
|
||||
* [jQuery Mobile](http://jquerymobile.com)
|
||||
* [jQuery UI](http://jqueryui.com/)
|
||||
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
|
||||
* [Knockout.js](http://knockoutjs.com/)
|
||||
* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping)
|
||||
* [linq.js](http://linqjs.codeplex.com/) (by Marcin Najder (https://github.com/marcinnajder))
|
||||
* [Modernizr](http://modernizr.com/)
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
* [Mustache.js](https://github.com/janl/mustache.js)
|
||||
* [Node.js](http://nodejs.org/) (from TypeScript samples)
|
||||
* [node_redis](https://github.com/mranney/node_redis)
|
||||
* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver)
|
||||
* [PhoneGap](http://phonegap.com)
|
||||
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall))
|
||||
* [Sammy.js](http://sammyjs.org/)
|
||||
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Spin](http://fgnass.github.com/spin.js/)
|
||||
* [Sugar](http://sugarjs.com/) (by Josh Baldwin)(https://github.com/jbaldwin/)
|
||||
* [Teechart](http://www.steema.com) (by [Steema]) (http://www.steema.com)
|
||||
* [Toastr](https://github.com/CodeSeven/toastr)
|
||||
* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Underscore.js](http://underscorejs.org/)
|
||||
* [Underscore.js (Typed)](http://underscorejs.org/) (by Josh Baldwin)(https://github.com/jbaldwin/)
|
||||
|
||||
Next
|
||||
----
|
||||
* Facebook SDK
|
||||
* jQuery.Validate
|
||||
* google.visualization
|
||||
* Meteor
|
||||
* Isotope
|
||||
* Zepto
|
||||
* Socket.IO
|
||||
* MongoDB
|
||||
@@ -0,0 +1,52 @@
|
||||
/// <reference path="../Definitions/toastr-1.0.d.ts" />
|
||||
|
||||
function test_basic() {
|
||||
toastr.info('Are you the 6 fingered man?');
|
||||
toastr.warning('My name is Inigo Montoya. You Killed my father, prepare to die!');
|
||||
toastr.success('Have fun storming the castle!', 'Miracle Max Says');
|
||||
toastr.error('I do not think that word means what you tink it means.', 'Inconceivable!');
|
||||
}
|
||||
|
||||
declare var $;
|
||||
function test_fromdemo() {
|
||||
$('#showtoast').click(function () {
|
||||
var shortCutFunction = $("#toastTypeGroup input:radio:checked").val(),
|
||||
msg = $('#message').val(),
|
||||
title = $('#title').val() || '',
|
||||
$fadeIn = $('#fadeIn'),
|
||||
$fadeOut = $('#fadeOut'),
|
||||
$timeOut = $('#timeOut'),
|
||||
$extendedTimeOut = $('#extendedTimeOut'),
|
||||
toastIndex = 123;
|
||||
toastr.options = {
|
||||
debug: $('#debugInfo').prop('checked'),
|
||||
tapToDismiss: $('#tapToDismiss').prop('checked'),
|
||||
positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right'
|
||||
}
|
||||
if ($fadeIn.val().length) {
|
||||
toastr.options.fadeIn = +$fadeIn.val()
|
||||
}
|
||||
if ($fadeOut.val().length) {
|
||||
toastr.options.fadeOut = +$fadeOut.val()
|
||||
}
|
||||
if ($timeOut.val().length) {
|
||||
toastr.options.timeOut = +$timeOut.val()
|
||||
}
|
||||
if ($extendedTimeOut.val().length) {
|
||||
toastr.options.extendedTimeOut = +$extendedTimeOut.val()
|
||||
}
|
||||
var $toast = toastr[shortCutFunction](msg, title)
|
||||
if ($toast.find('#okBtn').length) {
|
||||
$toast.on('click', '#okBtn', function () {
|
||||
alert('you clicked me. i was toast #' + toastIndex + '. goodbye!')
|
||||
$toast.remove()
|
||||
})
|
||||
}
|
||||
if ($toast.find('#surpriseBtn').length) {
|
||||
$toast.on('click', '#surpriseBtn', function () {
|
||||
alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.')
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user