1// Making any changes here will affect notifications platform wide 2// When making any drastic or specific changes consider cloning this 3// file and moving to a specific folder. 4PNotify.defaultModules.set(PNotifyBootstrap4); 5PNotify.defaultModules.set(PNotifyBootstrap4, {}); 6PNotify.defaultModules.set(PNotifyFontAwesome5Fix, {}); 7PNotify.defaultModules.set(PNotifyFontAwesome5, {}); 8 9pnotifyHelper = { 10 // Stacks 11 'bottom-right-stack': false, 12 'top-right-stack': false, 13 permittedPosistionsStacks : { 14 'bottom-right' : ["up", "top"], 15 'top-right' : ["down", "bottom"] 16 }, 17 permittedTypes : ['notice', 'success', 'error', 'info'], 18 maxOpen: 10, 19 modal: false, 20 spacing1: 15, 21 spacing2: 15, 22 firstpos1: 15, 23 firstpos2: 15, 24 dir2: "left", 25 getType: function (type) { 26 if (typeof type !== 'string') { 27 throw new Error('PNotify message type must be of type string'); 28 } 29 30 typeLowerCase = type.toLowerCase(); 31 if (typeLowerCase === 'warning') { 32 return 'notice'; 33 } 34 35 return typeLowerCase; 36 }, 37 getStack: function (position) { 38 var stackName = position + '-stack'; 39 if (this[stackName] === false) { 40 var stackConfig = this.getStackConfig(this.permittedPosistionsStacks[position]); 41 this[stackName] = new PNotify.Stack(stackConfig); 42 43 return this[stackName]; 44 } else { 45 // Stack already created. 46 // If we create another one notifications will display on top of each other. 47 return this[stackName]; 48 } 49 }, 50 getStackConfig(stackValues) { 51 return { 52 dir1: stackValues[0], 53 dir2: this.dir2, 54 firstpos1: this.firstpos1, 55 firstpos2: this.firstpos2, 56 spacing1: this.spacing1, 57 spacing2: this.spacing2, 58 push: stackValues[1], 59 modal: this.modal, 60 maxOpen: this.maxOpen 61 } 62 }, 63 validate: function (type, title, message, position, automaticallyRemove) { 64 // Type validation 65 if (typeof type !== 'string') { 66 throw new Error('Pnotify type must be of type string.'); 67 } 68 // Pnotify only allows these types 69 if (this.permittedTypes.indexOf(type) === -1) { 70 throw new Error('Pnotify type is invalid.'); 71 } 72 // Title validation. We do currently allow empty titles. 73 if (typeof title !== 'string') { 74 throw new Error('Pnotify title must be of type string.'); 75 } 76 // Message validation. We do currently allow empty titles. 77 if (typeof message !== 'string') { 78 throw new Error('Pnotify message must be of type string.'); 79 } 80 // Position validation 81 if (typeof position !== 'string') { 82 throw new Error('Pnotify position must be of type string.'); 83 } 84 // Check position is valid 85 if (this.permittedPosistionsStacks.hasOwnProperty(position) === false) { 86 throw new Error('Pnotify position is invalid.'); 87 } 88 // automaticallyRemove validation. 89 if (typeof automaticallyRemove !== 'boolean') { 90 throw new Error('Pnotify automaticallyRemove must be of type boolean.'); 91 } 92 }, 93 createMessage: function (type, title, message, position, automaticallyRemove) { 94 var position = position || 'top-right'; 95 var automaticallyRemove = automaticallyRemove || true; 96 this.validate(type, title, message, position, automaticallyRemove); 97 return PNotify[type]({ 98 title: title, 99 text: message, 100 icon: false, 101 hide: automaticallyRemove, 102 delay: 5000, 103 sticker: false, 104 stack: this.getStack(position), 105 maxOpen: 10, 106 closerHover: false, 107 autoOpen: true, 108 stickerHover: false 109 }); 110 } 111};
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.