Last active
August 29, 2015 14:15
Revisions
-
robertd revised this gist
Feb 20, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,6 @@ define([ }, function (err) { toast.setType("error") .setMessage("Something went wrong") .setNewTimeout(5000); }); }); -
robertd revised this gist
Feb 20, 2015 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,9 +10,10 @@ define([ }).then(function (data) { toast.setType("success") .setMessage("Successfully fetched " + response.length + " repositories.") .setNewTimeout(5000); }, function (err) { toast.setType("error") .setMessage("Something went wrong") .setNewTimeout(5000);; }); }); -
robertd revised this gist
Feb 20, 2015 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ define([ "notifier" "jquery" ], function (notifier, $) { /* ACME Demo */ var toast = notifier.instance("info", "Fetching..."); // toastr insance that can be manipulated later $.ajax("/api/acme/repositories", { dataType: "json" }).then(function (data) { toast.setType("success") .setMessage("Successfully fetched " + response.length + " repositories.") .setNewTimeout(); }, function (err) { toast.setType("error") .setMessage("Something went wrong"); }); }); -
robertd renamed this gist
Feb 20, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
robertd created this gist
Feb 20, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,91 @@ define([ "jquery", "toastr" ], function ($, toastr) { toastr.options = { "closeButton": false, "debug": false, "progressBar": false, "positionClass": "toast-bottom-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "3000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" }; var success = function (msg, options, title) { options = options || {}; title = title || ""; toastr.success(msg, title, options); }; var info = function (msg, options, title) { options = options || {}; title = title || ""; toastr.info(msg, title, options); }; var error = function (msg, options, title) { options = options || {}; title = title || ""; toastr.error(msg, title, options); }; var warning = function (msg, options, title) { options = options || {}; title = title || ""; toastr.warning(msg, title, options); }; var clear = function () { toastr.clear(); }; var instance = function (type, msg) { var _instance = toastr[type](msg, null, { timeOut: 0 }); var setMessage = function (msg) { _instance.text(msg); return this; }; var setType = function (type) { $(_instance).removeClass(function (index, css) { return (css.match(/(^|\s)toast-\S+/g) || []).join(' '); }).addClass("toast-" + type); return this; }; var setNewTimeout = function (timeout) { timeout = timeout || 3000; setTimeout(function(){ _instance.remove(); }, timeout); return this; }; return { setMessage: setMessage, setType: setType, setNewTimeout: setNewTimeout }; }; return { success: success, info: info, error: error, warning: warning, clear: clear, instance: instance }; });