1//JS for notifications. Centralized calling to notification plugins 2//so that we can switch the implemented notification plugin in and out 3//without ever having to change the consuming code 4 5var notificationService = new function () { 6 //the default postion for the notification 7 var defaultPostion = 'toast-top-right'; 8 //The default options to pass to the plugins 9 var defaultOptions = { positionClass: defaultPostion }; 10 //error options to pass to the plugin 11 //in case of errrors we don't want to 12 //fade out the error automatically so it needs to be 13 //cleared explicitly by the user 14 var defaultErrorOptions = { 15 "debug": false, 16 "positionClass": defaultPostion, 17 "onclick": null, 18 "fadeIn": 300, 19 "timeOut": 0 20 } 21 22 var defaultInfoOptions = { 23 "debug": false, 24 "positionClass": defaultPostion, 25 "onclick": null, 26 "fadeIn": 300, 27 "timeOut": 0 28 } 29 30 var infoOptionsWithTimeout = { 31 "debug": false, 32 "positionClass": defaultPostion, 33 "onclick": null, 34 "fadeIn": 300, 35 "timeOut": 6000 36 } 37 38 //show a generic save success 39 var ShowGenericSavedSuccess = function () { 40 toastr.success('Data saved successfully', '', defaultOptions); 41 } 42 43 //show a specific saved or created message 44 //with replacement text for the type of 45 //object we have just saved 46 var ShowSpecificSuccessReplace = function (replace, create) { 47 var savedText = 'saved'; 48 if (create == true) 49 savedText = 'created'; 50 toastr.success(replace + ' ' + savedText + ' successfully', '', defaultOptions); 51 } 52 53 //show a success message but with a fully customized 54 //message 55 var ShowSpecificSuccess = function (message) { 56 toastr.success(message, '', defaultOptions); 57 } 58 59 //show a generic successful delete 60 //message with default options 61 var ShowGenericDeleteSuccess = function () { 62 toastr.success('Data deleted successfully', '', defaultOptions); 63 } 64 65 //show a specific successful delete 66 //message with default options 67 var ShowSpecificDeleteSuccess = function (replace) { 68 toastr.success(replace + ' was deleted successfully', '', defaultOptions); 69 } 70 71 //show information to the user 72 //with a specific message 73 //using the default options 74 var ShowInfo = function (message) { 75 toastr.info(message, '', defaultInfoOptions); 76 } 77 78 //show information to the user 79 //with a specific message 80 //using the default options 81 var ShowInfoWithFade = function (message) { 82 toastr.info(message, '', infoOptionsWithTimeout); 83 } 84 85 //show a generic error with not 86 //specific information about the error 87 //This should be used very restrictively 88 //and only as a last resort 89 var ShowGenericError = function () { 90 toastr.error('Sorry something went wrong. If the problem persists please contact support.', '', defaultErrorOptions); 91 } 92 93 //Show a specific error message 94 //with default error options 95 var ShowSpecificError = function (error) { 96 toastr.error(error, '', defaultErrorOptions); 97 } 98 99 var ShowInvalidFormMessage = function () { 100 ShowInfo('There is a problem with the form. Please check the validation messages.'); 101 } 102 103 //expose the functions we want to expose 104 return { 105 ShowGenericSavedSuccess: ShowGenericSavedSuccess, 106 ShowSpecificSuccessReplace: ShowSpecificSuccessReplace, 107 ShowSpecificSuccess: ShowSpecificSuccess, 108 ShowGenericDeleteSuccess: ShowGenericDeleteSuccess, 109 ShowSpecificDeleteSuccess: ShowSpecificDeleteSuccess, 110 ShowInfo: ShowInfo, 111 ShowGenericError: ShowGenericError, 112 ShowSpecificError: ShowSpecificError, 113 ShowInvalidFormMessage: ShowInvalidFormMessage, 114 ShowInfoWithFade: ShowInfoWithFade 115 }; 116 117}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.