Skip to content

Commit

Permalink
renamed to toastr
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpapa committed May 1, 2012
1 parent b4d21c0 commit 035ee4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
27 changes: 17 additions & 10 deletions index.html
Expand Up @@ -2,7 +2,8 @@
<html> <html>
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title>toastR examples</title> <title>toastr examples</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"/> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"/>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet"/> <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="toastr.css" rel="stylesheet" type="text/css" /> <link href="toastr.css" rel="stylesheet" type="text/css" />
Expand All @@ -16,7 +17,7 @@


<body style="padding: 30px" class="container"> <body style="padding: 30px" class="container">
<section class="row"> <section class="row">
<h1>toastR</h1> <h1>toastr</h1>


<div class="well row"> <div class="well row">
<div class="row span11"> <div class="row span11">
Expand Down Expand Up @@ -93,8 +94,8 @@ <h1>toastR</h1>
<h2>Links</h2> <h2>Links</h2>


<ul> <ul>
<li><a href="https://github.com/downloads/KnockedUp/toastR/toastr.zip">Download</a></li> <li><a href="https://github.com/downloads/CodeSeven/toastr/toastr.zip">Download</a></li>
<li><a href="https://github.com/KnockedUp/toastR">GitHub</a></li> <li><a href="https://github.com/CodeSeven/toastr">GitHub</a></li>
</ul> </ul>
</footer> </footer>


Expand All @@ -108,7 +109,7 @@ <h2>Links</h2>
toastCount = 0, toastCount = 0,
getMessage = function() { getMessage = function() {
var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!', var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!',
'<div><input class="input-small" value="textbox"/></div><div><a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><label>Check me</label><input type="checkbox"/><button type="button" id="okBtn" class="btn btn-primary">Close me</button></div>', '<div><input class="input-small" value="textbox"/>&nbsp;<a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',
'Are you the six fingered man?', 'Are you the six fingered man?',
'Inconceivable!', 'Inconceivable!',
'I do not think that means what you think it means.', 'I do not think that means what you think it means.',
Expand All @@ -132,29 +133,29 @@ <h2>Links</h2>
toastIndex = toastCount++ toastIndex = toastCount++




toastR.options = { toastr.options = {
debug: $('#debugInfo').prop('checked'), debug: $('#debugInfo').prop('checked'),
tapToDismiss: $('#tapToDismiss').prop('checked'), tapToDismiss: $('#tapToDismiss').prop('checked'),
positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right' positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right'
} }


if ($fadeIn.val().length) { if ($fadeIn.val().length) {
toastR.options.fadeIn = +$fadeIn.val() toastr.options.fadeIn = +$fadeIn.val()
} }


if ($fadeOut.val().length) { if ($fadeOut.val().length) {
toastR.options.fadeOut = +$fadeOut.val() toastr.options.fadeOut = +$fadeOut.val()
} }


if ($timeOut.val().length) { if ($timeOut.val().length) {
toastR.options.timeOut = +$timeOut.val() toastr.options.timeOut = +$timeOut.val()
} }


if (!msg) { if (!msg) {
msg = getMessage() msg = getMessage()
} }


var $toast = toastR[shortCutFunction](msg, title) var $toast = toastr[shortCutFunction](msg, title)


// Wire up an event handler to a button in the toast, if it exists // Wire up an event handler to a button in the toast, if it exists
if ($toast.find('#okBtn').length) { if ($toast.find('#okBtn').length) {
Expand All @@ -163,6 +164,12 @@ <h2>Links</h2>
$toast.remove() $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.')
})
}

}) })
}) })
</script> </script>
Expand Down
6 changes: 3 additions & 3 deletions toastr.js
@@ -1,11 +1,11 @@
// By: Hans Fjällemark and John Papa // By: Hans Fjällemark and John Papa
// https://github.com/KnockedUp/toastR // https://github.com/CodeSeven/toastr
// //
// Modified to support css styling instead of inline styling // Modified to support css styling instead of inline styling
// Based on original version at https://github.com/Srirangan/notifer.js/ // Based on original version at https://github.com/Srirangan/notifer.js/


(function (window, $) { (function (window, $) {
window.toastR = (function () { window.toastr = (function () {
var var
defaults = { defaults = {
tapToDismiss: true, tapToDismiss: true,
Expand Down Expand Up @@ -52,7 +52,7 @@
}, },


getOptions = function () { getOptions = function () {
return $.extend({}, defaults, toastR.options) return $.extend({}, defaults, toastr.options)
}, },


info = function (message, title) { info = function (message, title) {
Expand Down

0 comments on commit 035ee4a

Please sign in to comment.