Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed selector typo in test #542

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
.row {
margin-left: 0;
}
.toast-custom {
background-color: #0000A0;
background-image: url("data:image/gif;base64,R0lGOD lhCwAOAMQfAP////7+/vj4+Hh4eHd3d/v7+/Dw8HV1dfLy8ubm5vX19e3t7fr 6+nl5edra2nZ2dnx8fMHBwYODg/b29np6eujo6JGRkeHh4eTk5LCwsN3d3dfX 13Jycp2dnevr6////yH5BAEAAB8ALAAAAAALAA4AAAVq4NFw1DNAX/o9imAsB tKpxKRd1+YEWUoIiUoiEWEAApIDMLGoRCyWiKThenkwDgeGMiggDLEXQkDoTh CKNLpQDgjeAsY7MHgECgx8YR8oHwNHfwADBACGh4EDA4iGAYAEBAcQIg0Dk gcEIQA7") !important;
}
</style>
</head>

Expand Down Expand Up @@ -93,6 +97,13 @@ <h1>toastr</h1>
<label class="radio">
<input type="radio" name="toasts" value="error" />Error
</label>
<label class="radio">
<input type="radio" name="toasts" value="custom" />Custom
</label>
<div id="customClassContainer" style="display:none">
<label class="control-label" for="customClass">Icon Class</label>
<input id="customClass" type="text" class="input-small" value="toast-custom" />
</div>
</div>
</div>
<div class="control-group" id="positionGroup">
Expand Down Expand Up @@ -215,6 +226,15 @@ <h2>Links</h2>
return msg;
};

$('#toastTypeGroup').click(function() {
var toastType = $("#toastTypeGroup input:radio:checked").val();
if (toastType === 'custom') {
$('#customClassContainer').show();
} else {
$('#customClassContainer').hide();
}
});

$('#closeButton').click(function() {
if($(this).is(':checked')) {
$('#addBehaviorOnToastCloseClick').prop('disabled', false);
Expand Down Expand Up @@ -249,6 +269,9 @@ <h2>Links</h2>
preventDuplicates: $('#preventDuplicates').prop('checked'),
onclick: null
};
if (shortCutFunction === 'custom') {
toastr.options.iconClass = $('#customClass').val();
}

if ($('#addBehaviorOnToastClick').prop('checked')) {
toastr.options.onclick = function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/toastr-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
var selectors = {
container: 'div#toast-container',
toastInfo: 'div#toast-container > div.toast-info',
toastWarning: 'div#toast-container > div.toast-success',
toastWarning: 'div#toast-container > div.toast-warning',
toastError: 'div#toast-container > div.toast-error',
toastSuccess: 'div#toast-container > div.toast-success'
};
Expand Down
14 changes: 13 additions & 1 deletion toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
error: 'error',
info: 'info',
success: 'success',
warning: 'warning'
warning: 'warning',
custom: 'custom'
};

var toastr = {
clear: clear,
custom: custom,
remove: remove,
error: error,
getContainer: getContainer,
Expand Down Expand Up @@ -99,6 +101,16 @@
});
}

function custom(message, title, optionsOverride) {
return notify({
type: toastType.custom,
iconClass: getOptions().iconClass,
message: message,
optionsOverride: optionsOverride,
title: title
});
}

function clear($toastElement, clearOptions) {
var options = getOptions();
if (!$container) { getContainer(options); }
Expand Down