├── README.md ├── pNotify ├── __resource.lua ├── html │ ├── pNotify.js │ ├── index.html │ ├── noty_license.txt │ ├── themes.css │ ├── noty.css │ └── noty.js └── cl_notify.lua └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # pNotify 2 | In-game notifications for the FiveM GTA V mod 3 | 4 | instructions / examples [here](https://forum.fivem.net/t/release-pnotify-in-game-js-notifications-using-noty/20659/1) 5 | -------------------------------------------------------------------------------- /pNotify/__resource.lua: -------------------------------------------------------------------------------- 1 | description "Simple Notification Script using https://notifyjs.com/" 2 | 3 | ui_page "html/index.html" 4 | 5 | client_script "cl_notify.lua" 6 | 7 | export "SetQueueMax" 8 | export "SendNotification" 9 | 10 | files { 11 | "html/index.html", 12 | "html/pNotify.js", 13 | "html/noty.js", 14 | "html/noty.css", 15 | "html/themes.css", 16 | "html/sound-example.wav" 17 | } -------------------------------------------------------------------------------- /pNotify/html/pNotify.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | window.addEventListener("message", function(event){ 3 | if(event.data.options){ 4 | var options = event.data.options; 5 | new Noty(options).show(); 6 | }else{ 7 | var maxNotifications = event.data.maxNotifications; 8 | Noty.setMaxVisible(maxNotifications.max, maxNotifications.queue); 9 | }; 10 | }); 11 | }); -------------------------------------------------------------------------------- /pNotify/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pNotify 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nick78111 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pNotify/html/noty_license.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2012 Nedim Arabacı 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /pNotify/html/themes.css: -------------------------------------------------------------------------------- 1 | .noty_theme__gta.noty_bar { 2 | margin: 4px 0; 3 | overflow: hidden; 4 | border-radius: 1px; 5 | font-family: sans-serif; 6 | position: relative; 7 | height: auto; 8 | word-wrap: break-word; 9 | } 10 | 11 | .noty_theme__gta.noty_bar .noty_body { 12 | padding: 8px; 13 | font-size: 14px; 14 | } 15 | 16 | .noty_theme__gta.noty_bar .noty_buttons { 17 | padding: 0px; 18 | } 19 | 20 | .noty_theme__gta.noty_bar .noty_progressbar { 21 | position: absolute; 22 | left: 0; 23 | bottom: 0; 24 | height: 1px; 25 | width: 100%; 26 | background-color: white; 27 | opacity: 0.8; 28 | filter: alpha(opacity=80); 29 | } 30 | 31 | .noty_theme__gta.noty_type__alert, 32 | .noty_theme__gta.noty_type__notification { 33 | background-color: rgb(40, 40, 40); 34 | border-top: 2px solid #D1D1D1; 35 | color: white; 36 | } 37 | 38 | .noty_theme__gta.noty_type__warning { 39 | background-color: rgb(40, 40, 40); 40 | border-top: 2px solid #E89F3C; 41 | color: white; 42 | } 43 | 44 | .noty_theme__gta.noty_type__error { 45 | background-color: rgb(40, 40, 40); 46 | border-top: 2px solid #CA5A65; 47 | color: #fff; 48 | } 49 | 50 | .noty_theme__gta.noty_type__info, 51 | .noty_theme__gta.noty_type__information { 52 | background-color: rgb(40, 40, 40); 53 | border-top: 2px solid #7473E8; 54 | color: #fff; 55 | } 56 | 57 | .noty_theme__gta.noty_type__success { 58 | background-color: rgb(40, 40, 40); 59 | border-top: 2px solid #A0B55C; 60 | color: #fff; 61 | } 62 | 63 | .gta_effects_open { 64 | opacity: 0; 65 | -webkit-transform: translate(50%); 66 | -ms-transform: translate(50%); 67 | transform: translate(50%); 68 | -webkit-animation: noty_anim_in 0.5s cubic-bezier(0.215, 0.61, 0.355, 1); 69 | animation: noty_anim_in 0.5s cubic-bezier(0.215, 0.61, 0.355, 1); 70 | -webkit-animation-fill-mode: forwards; 71 | animation-fill-mode: forwards; 72 | } 73 | 74 | .gta_effects_close { 75 | -webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 76 | animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 77 | -webkit-animation-fill-mode: forwards; 78 | animation-fill-mode: forwards; 79 | } 80 | 81 | @-webkit-keyframes noty_anim_out_left { 82 | 100% { 83 | -webkit-transform: translate(-50%); 84 | transform: translate(-50%); 85 | opacity: 0; } } 86 | 87 | @keyframes noty_anim_out_left { 88 | 100% { 89 | -webkit-transform: translate(-50%); 90 | transform: translate(-50%); 91 | opacity: 0; } } 92 | 93 | .gta_effects_open_left { 94 | opacity: 0; 95 | -webkit-transform: translate(-50%); 96 | -ms-transform: translate(-50%); 97 | transform: translate(-50%); 98 | -webkit-animation: noty_anim_in 0.5s cubic-bezier(0.215, 0.61, 0.355, 1); 99 | animation: noty_anim_in 0.5s cubic-bezier(0.215, 0.61, 0.355, 1); 100 | -webkit-animation-fill-mode: forwards; 101 | animation-fill-mode: forwards; 102 | } 103 | 104 | .gta_effects_close_left { 105 | -webkit-animation: noty_anim_out_left 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 106 | animation: noty_anim_out_left 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 107 | -webkit-animation-fill-mode: backwards; 108 | animation-fill-mode: backwards; 109 | } 110 | 111 | @-webkit-keyframes noty_anim_fade_in { 112 | 100% { opacity: 1; } } 113 | 114 | @keyframes noty_anim_fade_in { 115 | 100% { opacity: 1; } } 116 | 117 | @-webkit-keyframes noty_anim_fade_out { 118 | 100% { opacity: 0; } } 119 | 120 | @keyframes noty_anim_fade_out { 121 | 100% { opacity: 0; } } 122 | 123 | .gta_effects_fade_in { 124 | opacity: 0; 125 | animation: noty_anim_fade_in 0.5s; 126 | } 127 | 128 | .gta_effects_fade_out { 129 | opacity: 1; 130 | animation: noty_anim_fade_out 0.5s; 131 | } -------------------------------------------------------------------------------- /pNotify/cl_notify.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Complete List of Options: 3 | type 4 | layout 5 | theme 6 | text 7 | timeout 8 | progressBar 9 | closeWith 10 | animation = { 11 | open 12 | close 13 | } 14 | sounds = { 15 | volume 16 | conditions 17 | sources 18 | } 19 | docTitle = { 20 | conditions 21 | } 22 | modal 23 | id 24 | force 25 | queue 26 | killer 27 | container 28 | buttons 29 | 30 | More details below or visit the creators website http://ned.im/noty/options.html 31 | 32 | Layouts: 33 | top 34 | topLeft 35 | topCenter 36 | topRight 37 | center 38 | centerLeft 39 | centerRight 40 | bottom 41 | bottomLeft 42 | bottomCenter 43 | bottomRight 44 | 45 | Types: 46 | alert 47 | success 48 | error 49 | warning 50 | info 51 | 52 | Themes: -- You can create more themes inside html/themes.css, use the gta theme as a template. 53 | gta 54 | mint 55 | relax 56 | metroui 57 | 58 | Animations: 59 | open: 60 | noty_effects_open 61 | gta_effects_open 62 | gta_effects_open_left 63 | gta_effects_fade_in 64 | close: 65 | noty_effects_close 66 | gta_effects_close 67 | gta_effects_close_left 68 | gta_effects_fade_out 69 | 70 | closeWith: -- array, You will probably never use this. 71 | click 72 | button 73 | 74 | sounds: 75 | volume: 0.0 - 1.0 76 | conditions: -- array 77 | docVisible 78 | docHidden 79 | sources: -- array of sound files 80 | 81 | modal: 82 | true 83 | false 84 | 85 | force: 86 | true 87 | false 88 | 89 | queue: -- default is global, you can make it what ever you want though. 90 | global 91 | 92 | killer: -- will close all visible notifications and show only this one 93 | true 94 | false 95 | 96 | visit the creators website http://ned.im/noty/options.html for more information 97 | --]] 98 | 99 | function SetQueueMax(queue, max) 100 | local tmp = { 101 | queue = tostring(queue), 102 | max = tonumber(max) 103 | } 104 | 105 | SendNUIMessage({maxNotifications = tmp}) 106 | end 107 | 108 | function SendNotification(options) 109 | options.animation = options.animation or {} 110 | options.sounds = options.sounds or {} 111 | options.docTitle = options.docTitle or {} 112 | 113 | local options = { 114 | type = options.type or "success", 115 | layout = options.layout or "topRight", 116 | theme = options.theme or "gta", 117 | text = options.text or "Empty Notification", 118 | timeout = options.timeout or 5000, 119 | progressBar = options.progressBar ~= false and true or false, 120 | closeWith = options.closeWith or {}, 121 | animation = { 122 | open = options.animation.open or "gta_effects_open", 123 | close = options.animation.close or "gta_effects_close" 124 | }, 125 | sounds = { 126 | volume = options.sounds.volume or 1, 127 | conditions = options.sounds.conditions or {}, 128 | sources = options.sounds.sources or {} 129 | }, 130 | docTitle = { 131 | conditions = options.docTitle.conditions or {} 132 | }, 133 | modal = options.modal or false, 134 | id = options.id or false, 135 | force = options.force or false, 136 | queue = options.queue or "global", 137 | killer = options.killer or false, 138 | container = options.container or false, 139 | buttons = options.button or false 140 | } 141 | 142 | SendNUIMessage({options = options}) 143 | end 144 | 145 | RegisterNetEvent("pNotify:SendNotification") 146 | AddEventHandler("pNotify:SendNotification", function(options) 147 | SendNotification(options) 148 | end) 149 | 150 | RegisterNetEvent("pNotify:SetQueueMax") 151 | AddEventHandler("pNotify:SetQueueMax", function(queue, max) 152 | SetQueueMax(queue, max) 153 | end) 154 | 155 | --[[RegisterNetEvent("chatMessage") 156 | AddEventHandler("chatMessage", function(author, color, text) 157 | TriggerEvent("pNotify:SendNotification", {text = "" .. text .. "", 158 | layout = "centerLeft", 159 | timeout = 2000, 160 | progressBar = false, 161 | type = "error", 162 | animation = { 163 | open = "gta_effects_fade_in", 164 | close = "gta_effects_fade_out" 165 | }}) 166 | end)]] -------------------------------------------------------------------------------- /pNotify/html/noty.css: -------------------------------------------------------------------------------- 1 | .noty_layout_mixin, #noty_layout__top, #noty_layout__topLeft, #noty_layout__topCenter, #noty_layout__topRight, #noty_layout__bottom, #noty_layout__bottomLeft, #noty_layout__bottomCenter, #noty_layout__bottomRight, #noty_layout__center, #noty_layout__centerLeft, #noty_layout__centerRight { 2 | position: fixed; 3 | margin: 0; 4 | padding: 0; 5 | z-index: 9999999; 6 | -webkit-transform: translateZ(0) scale(1, 1); 7 | transform: translateZ(0) scale(1, 1); 8 | -webkit-backface-visibility: hidden; 9 | backface-visibility: hidden; 10 | -webkit-font-smoothing: subpixel-antialiased; 11 | filter: blur(0); 12 | -webkit-filter: blur(0); 13 | max-width: 90%; } 14 | 15 | #noty_layout__top { 16 | top: 0; 17 | left: 5%; 18 | width: 90%; } 19 | 20 | #noty_layout__topLeft { 21 | top: 20px; 22 | left: 20px; 23 | width: 325px; } 24 | 25 | #noty_layout__topCenter { 26 | top: 5%; 27 | left: 50%; 28 | width: 325px; 29 | -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); 30 | transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } 31 | 32 | #noty_layout__topRight { 33 | top: 20px; 34 | right: 20px; 35 | width: 325px; } 36 | 37 | #noty_layout__bottom { 38 | bottom: 0; 39 | left: 5%; 40 | width: 90%; } 41 | 42 | #noty_layout__bottomLeft { 43 | bottom: 20px; 44 | left: 20px; 45 | width: 325px; } 46 | 47 | #noty_layout__bottomCenter { 48 | bottom: 5%; 49 | left: 50%; 50 | width: 325px; 51 | -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); 52 | transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } 53 | 54 | #noty_layout__bottomRight { 55 | bottom: 20px; 56 | right: 20px; 57 | width: 325px; } 58 | 59 | #noty_layout__center { 60 | top: 50%; 61 | left: 50%; 62 | width: 325px; 63 | -webkit-transform: translate(-webkit-calc(-50% - .5px), -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); 64 | transform: translate(calc(-50% - .5px), calc(-50% - .5px)) translateZ(0) scale(1, 1); } 65 | 66 | #noty_layout__centerLeft { 67 | top: 50%; 68 | left: 20px; 69 | width: 325px; 70 | -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); 71 | transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } 72 | 73 | #noty_layout__centerRight { 74 | top: 50%; 75 | right: 20px; 76 | width: 325px; 77 | -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); 78 | transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } 79 | 80 | .noty_progressbar { 81 | display: none; } 82 | 83 | .noty_has_timeout .noty_progressbar { 84 | display: block; 85 | position: absolute; 86 | left: 0; 87 | bottom: 0; 88 | height: 3px; 89 | width: 100%; 90 | background-color: #646464; 91 | opacity: 0.2; 92 | filter: alpha(opacity=10); } 93 | 94 | .noty_bar { 95 | -webkit-backface-visibility: hidden; 96 | -webkit-transform: translate(0, 0) translateZ(0) scale(1, 1); 97 | -ms-transform: translate(0, 0) scale(1, 1); 98 | transform: translate(0, 0) scale(1, 1); 99 | -webkit-font-smoothing: subpixel-antialiased; 100 | overflow: hidden; } 101 | 102 | .noty_effects_open { 103 | opacity: 0; 104 | -webkit-transform: translate(50%); 105 | -ms-transform: translate(50%); 106 | transform: translate(50%); 107 | -webkit-animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 108 | animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 109 | -webkit-animation-fill-mode: forwards; 110 | animation-fill-mode: forwards; } 111 | 112 | .noty_effects_close { 113 | -webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 114 | animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); 115 | -webkit-animation-fill-mode: forwards; 116 | animation-fill-mode: forwards; } 117 | 118 | .noty_fix_effects_height { 119 | -webkit-animation: noty_anim_height 75ms ease-out; 120 | animation: noty_anim_height 75ms ease-out; } 121 | 122 | .noty_close_with_click { 123 | cursor: pointer; } 124 | 125 | .noty_close_button { 126 | position: absolute; 127 | top: 2px; 128 | right: 2px; 129 | font-weight: bold; 130 | width: 20px; 131 | height: 20px; 132 | text-align: center; 133 | line-height: 20px; 134 | background-color: rgba(0, 0, 0, 0.05); 135 | border-radius: 2px; 136 | cursor: pointer; 137 | -webkit-transition: all .2s ease-out; 138 | transition: all .2s ease-out; } 139 | 140 | .noty_close_button:hover { 141 | background-color: rgba(0, 0, 0, 0.1); } 142 | 143 | .noty_modal { 144 | position: fixed; 145 | width: 100%; 146 | height: 100%; 147 | background-color: #000; 148 | z-index: 10000; 149 | opacity: .3; 150 | left: 0; 151 | top: 0; } 152 | 153 | .noty_modal.noty_modal_open { 154 | opacity: 0; 155 | -webkit-animation: noty_modal_in .3s ease-out; 156 | animation: noty_modal_in .3s ease-out; } 157 | 158 | .noty_modal.noty_modal_close { 159 | -webkit-animation: noty_modal_out .3s ease-out; 160 | animation: noty_modal_out .3s ease-out; 161 | -webkit-animation-fill-mode: forwards; 162 | animation-fill-mode: forwards; } 163 | 164 | @-webkit-keyframes noty_modal_in { 165 | 100% { 166 | opacity: .3; } } 167 | 168 | @keyframes noty_modal_in { 169 | 100% { 170 | opacity: .3; } } 171 | 172 | @-webkit-keyframes noty_modal_out { 173 | 100% { 174 | opacity: 0; } } 175 | 176 | @keyframes noty_modal_out { 177 | 100% { 178 | opacity: 0; } } 179 | 180 | @keyframes noty_modal_out { 181 | 100% { 182 | opacity: 0; } } 183 | 184 | @-webkit-keyframes noty_anim_in { 185 | 100% { 186 | -webkit-transform: translate(0); 187 | transform: translate(0); 188 | opacity: 1; } } 189 | 190 | @keyframes noty_anim_in { 191 | 100% { 192 | -webkit-transform: translate(0); 193 | transform: translate(0); 194 | opacity: 1; } } 195 | 196 | @-webkit-keyframes noty_anim_out { 197 | 100% { 198 | -webkit-transform: translate(50%); 199 | transform: translate(50%); 200 | opacity: 0; } } 201 | 202 | @keyframes noty_anim_out { 203 | 100% { 204 | -webkit-transform: translate(50%); 205 | transform: translate(50%); 206 | opacity: 0; } } 207 | 208 | @-webkit-keyframes noty_anim_height { 209 | 100% { 210 | height: 0; } } 211 | 212 | @keyframes noty_anim_height { 213 | 100% { 214 | height: 0; } } 215 | 216 | .noty_theme__relax.noty_bar { 217 | margin: 4px 0; 218 | overflow: hidden; 219 | border-radius: 2px; 220 | position: relative; } 221 | .noty_theme__relax.noty_bar .noty_body { 222 | padding: 10px; } 223 | .noty_theme__relax.noty_bar .noty_buttons { 224 | border-top: 1px solid #e7e7e7; 225 | padding: 5px 10px; } 226 | 227 | .noty_theme__relax.noty_type__alert, 228 | .noty_theme__relax.noty_type__notification { 229 | background-color: #fff; 230 | border: 1px solid #dedede; 231 | color: #444; } 232 | 233 | .noty_theme__relax.noty_type__warning { 234 | background-color: #FFEAA8; 235 | border: 1px solid #FFC237; 236 | color: #826200; } 237 | .noty_theme__relax.noty_type__warning .noty_buttons { 238 | border-color: #dfaa30; } 239 | 240 | .noty_theme__relax.noty_type__error { 241 | background-color: #FF8181; 242 | border: 1px solid #e25353; 243 | color: #FFF; } 244 | .noty_theme__relax.noty_type__error .noty_buttons { 245 | border-color: darkred; } 246 | 247 | .noty_theme__relax.noty_type__info, 248 | .noty_theme__relax.noty_type__information { 249 | background-color: #78C5E7; 250 | border: 1px solid #3badd6; 251 | color: #FFF; } 252 | .noty_theme__relax.noty_type__info .noty_buttons, 253 | .noty_theme__relax.noty_type__information .noty_buttons { 254 | border-color: #0B90C4; } 255 | 256 | .noty_theme__relax.noty_type__success { 257 | background-color: #BCF5BC; 258 | border: 1px solid #7cdd77; 259 | color: darkgreen; } 260 | .noty_theme__relax.noty_type__success .noty_buttons { 261 | border-color: #50C24E; } 262 | 263 | .noty_theme__metroui.noty_bar { 264 | margin: 4px 0; 265 | overflow: hidden; 266 | position: relative; 267 | box-shadow: rgba(0, 0, 0, 0.298039) 0 0 5px 0; } 268 | .noty_theme__metroui.noty_bar .noty_progressbar { 269 | position: absolute; 270 | left: 0; 271 | bottom: 0; 272 | height: 3px; 273 | width: 100%; 274 | background-color: #000; 275 | opacity: 0.2; 276 | filter: alpha(opacity=20); } 277 | .noty_theme__metroui.noty_bar .noty_body { 278 | padding: 1.25em; 279 | font-size: 14px; } 280 | .noty_theme__metroui.noty_bar .noty_buttons { 281 | padding: 0 10px .5em 10px; } 282 | 283 | .noty_theme__metroui.noty_type__alert, 284 | .noty_theme__metroui.noty_type__notification { 285 | background-color: #fff; 286 | color: #1d1d1d; } 287 | 288 | .noty_theme__metroui.noty_type__warning { 289 | background-color: #FA6800; 290 | color: #fff; } 291 | 292 | .noty_theme__metroui.noty_type__error { 293 | background-color: #CE352C; 294 | color: #FFF; } 295 | 296 | .noty_theme__metroui.noty_type__info, 297 | .noty_theme__metroui.noty_type__information { 298 | background-color: #1BA1E2; 299 | color: #FFF; } 300 | 301 | .noty_theme__metroui.noty_type__success { 302 | background-color: #60A917; 303 | color: #fff; } 304 | 305 | .noty_theme__mint.noty_bar { 306 | margin: 4px 0; 307 | overflow: hidden; 308 | border-radius: 2px; 309 | position: relative; } 310 | .noty_theme__mint.noty_bar .noty_body { 311 | padding: 10px; 312 | font-size: 14px; } 313 | .noty_theme__mint.noty_bar .noty_buttons { 314 | padding: 10px; } 315 | 316 | .noty_theme__mint.noty_type__alert, 317 | .noty_theme__mint.noty_type__notification { 318 | background-color: #fff; 319 | border-bottom: 1px solid #D1D1D1; 320 | color: #2F2F2F; } 321 | 322 | .noty_theme__mint.noty_type__warning { 323 | background-color: #FFAE42; 324 | border-bottom: 1px solid #E89F3C; 325 | color: #fff; } 326 | 327 | .noty_theme__mint.noty_type__error { 328 | background-color: #DE636F; 329 | border-bottom: 1px solid #CA5A65; 330 | color: #fff; } 331 | 332 | .noty_theme__mint.noty_type__info, 333 | .noty_theme__mint.noty_type__information { 334 | background-color: #7F7EFF; 335 | border-bottom: 1px solid #7473E8; 336 | color: #fff; } 337 | 338 | .noty_theme__mint.noty_type__success { 339 | background-color: #AFC765; 340 | border-bottom: 1px solid #A0B55C; 341 | color: #fff; } 342 | 343 | .noty_theme__sunset.noty_bar { 344 | margin: 4px 0; 345 | overflow: hidden; 346 | border-radius: 2px; 347 | position: relative; } 348 | .noty_theme__sunset.noty_bar .noty_body { 349 | padding: 10px; 350 | font-size: 14px; 351 | text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); } 352 | .noty_theme__sunset.noty_bar .noty_buttons { 353 | padding: 10px; } 354 | 355 | .noty_theme__sunset.noty_type__alert, 356 | .noty_theme__sunset.noty_type__notification { 357 | background-color: #073B4C; 358 | color: #fff; } 359 | .noty_theme__sunset.noty_type__alert .noty_progressbar, 360 | .noty_theme__sunset.noty_type__notification .noty_progressbar { 361 | background-color: #fff; } 362 | 363 | .noty_theme__sunset.noty_type__warning { 364 | background-color: #FFD166; 365 | color: #fff; } 366 | 367 | .noty_theme__sunset.noty_type__error { 368 | background-color: #EF476F; 369 | color: #fff; } 370 | .noty_theme__sunset.noty_type__error .noty_progressbar { 371 | opacity: .4; } 372 | 373 | .noty_theme__sunset.noty_type__info, 374 | .noty_theme__sunset.noty_type__information { 375 | background-color: #118AB2; 376 | color: #fff; } 377 | .noty_theme__sunset.noty_type__info .noty_progressbar, 378 | .noty_theme__sunset.noty_type__information .noty_progressbar { 379 | opacity: .6; } 380 | 381 | .noty_theme__sunset.noty_type__success { 382 | background-color: #06D6A0; 383 | color: #fff; } 384 | 385 | .noty_theme__bootstrap-v3.noty_bar { 386 | margin: 4px 0; 387 | overflow: hidden; 388 | position: relative; 389 | border: 1px solid transparent; 390 | border-radius: 4px; } 391 | .noty_theme__bootstrap-v3.noty_bar .noty_body { 392 | padding: 15px; } 393 | .noty_theme__bootstrap-v3.noty_bar .noty_buttons { 394 | padding: 10px; } 395 | .noty_theme__bootstrap-v3.noty_bar .noty_close_button { 396 | font-size: 21px; 397 | font-weight: 700; 398 | line-height: 1; 399 | color: #000; 400 | text-shadow: 0 1px 0 #fff; 401 | filter: alpha(opacity=20); 402 | opacity: .2; 403 | background: transparent; } 404 | .noty_theme__bootstrap-v3.noty_bar .noty_close_button:hover { 405 | background: transparent; 406 | text-decoration: none; 407 | cursor: pointer; 408 | filter: alpha(opacity=50); 409 | opacity: .5; } 410 | 411 | .noty_theme__bootstrap-v3.noty_type__alert, 412 | .noty_theme__bootstrap-v3.noty_type__notification { 413 | background-color: #fff; 414 | color: inherit; } 415 | 416 | .noty_theme__bootstrap-v3.noty_type__warning { 417 | background-color: #fcf8e3; 418 | color: #8a6d3b; 419 | border-color: #faebcc; } 420 | 421 | .noty_theme__bootstrap-v3.noty_type__error { 422 | background-color: #f2dede; 423 | color: #a94442; 424 | border-color: #ebccd1; } 425 | 426 | .noty_theme__bootstrap-v3.noty_type__info, 427 | .noty_theme__bootstrap-v3.noty_type__information { 428 | background-color: #d9edf7; 429 | color: #31708f; 430 | border-color: #bce8f1; } 431 | 432 | .noty_theme__bootstrap-v3.noty_type__success { 433 | background-color: #dff0d8; 434 | color: #3c763d; 435 | border-color: #d6e9c6; } 436 | 437 | .noty_theme__bootstrap-v4.noty_bar { 438 | margin: 4px 0; 439 | overflow: hidden; 440 | position: relative; 441 | border: 1px solid transparent; 442 | border-radius: .25rem; } 443 | .noty_theme__bootstrap-v4.noty_bar .noty_body { 444 | padding: .75rem 1.25rem; } 445 | .noty_theme__bootstrap-v4.noty_bar .noty_buttons { 446 | padding: 10px; } 447 | .noty_theme__bootstrap-v4.noty_bar .noty_close_button { 448 | font-size: 1.5rem; 449 | font-weight: 700; 450 | line-height: 1; 451 | color: #000; 452 | text-shadow: 0 1px 0 #fff; 453 | filter: alpha(opacity=20); 454 | opacity: .5; 455 | background: transparent; } 456 | .noty_theme__bootstrap-v4.noty_bar .noty_close_button:hover { 457 | background: transparent; 458 | text-decoration: none; 459 | cursor: pointer; 460 | filter: alpha(opacity=50); 461 | opacity: .75; } 462 | 463 | .noty_theme__bootstrap-v4.noty_type__alert, 464 | .noty_theme__bootstrap-v4.noty_type__notification { 465 | background-color: #fff; 466 | color: inherit; } 467 | 468 | .noty_theme__bootstrap-v4.noty_type__warning { 469 | background-color: #fcf8e3; 470 | color: #8a6d3b; 471 | border-color: #faebcc; } 472 | 473 | .noty_theme__bootstrap-v4.noty_type__error { 474 | background-color: #f2dede; 475 | color: #a94442; 476 | border-color: #ebccd1; } 477 | 478 | .noty_theme__bootstrap-v4.noty_type__info, 479 | .noty_theme__bootstrap-v4.noty_type__information { 480 | background-color: #d9edf7; 481 | color: #31708f; 482 | border-color: #bce8f1; } 483 | 484 | .noty_theme__bootstrap-v4.noty_type__success { 485 | background-color: #dff0d8; 486 | color: #3c763d; 487 | border-color: #d6e9c6; } 488 | 489 | .noty_theme__semanticui.noty_bar { 490 | margin: 4px 0; 491 | overflow: hidden; 492 | position: relative; 493 | border: 1px solid transparent; 494 | font-size: 1em; 495 | border-radius: .28571429rem; 496 | box-shadow: 0 0 0 1px rgba(34, 36, 38, 0.22) inset, 0 0 0 0 transparent; } 497 | .noty_theme__semanticui.noty_bar .noty_body { 498 | padding: 1em 1.5em; 499 | line-height: 1.4285em; } 500 | .noty_theme__semanticui.noty_bar .noty_buttons { 501 | padding: 10px; } 502 | 503 | .noty_theme__semanticui.noty_type__alert, 504 | .noty_theme__semanticui.noty_type__notification { 505 | background-color: #f8f8f9; 506 | color: rgba(0, 0, 0, 0.87); } 507 | 508 | .noty_theme__semanticui.noty_type__warning { 509 | background-color: #fffaf3; 510 | color: #573a08; 511 | box-shadow: 0 0 0 1px #c9ba9b inset, 0 0 0 0 transparent; } 512 | 513 | .noty_theme__semanticui.noty_type__error { 514 | background-color: #fff6f6; 515 | color: #9f3a38; 516 | box-shadow: 0 0 0 1px #e0b4b4 inset, 0 0 0 0 transparent; } 517 | 518 | .noty_theme__semanticui.noty_type__info, 519 | .noty_theme__semanticui.noty_type__information { 520 | background-color: #f8ffff; 521 | color: #276f86; 522 | box-shadow: 0 0 0 1px #a9d5de inset, 0 0 0 0 transparent; } 523 | 524 | .noty_theme__semanticui.noty_type__success { 525 | background-color: #fcfff5; 526 | color: #2c662d; 527 | box-shadow: 0 0 0 1px #a3c293 inset, 0 0 0 0 transparent; } 528 | 529 | .noty_theme__nest.noty_bar { 530 | margin: 0 0 15px 0; 531 | overflow: hidden; 532 | border-radius: 2px; 533 | position: relative; 534 | box-shadow: rgba(0, 0, 0, 0.098039) 5px 4px 10px 0; } 535 | .noty_theme__nest.noty_bar .noty_body { 536 | padding: 10px; 537 | font-size: 14px; 538 | text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); } 539 | .noty_theme__nest.noty_bar .noty_buttons { 540 | padding: 10px; } 541 | 542 | .noty_layout .noty_theme__nest.noty_bar { 543 | z-index: 5; } 544 | 545 | .noty_layout .noty_theme__nest.noty_bar:nth-child(2) { 546 | position: absolute; 547 | top: 0; 548 | margin-top: 4px; 549 | margin-right: -4px; 550 | margin-left: 4px; 551 | z-index: 4; 552 | width: 100%; } 553 | 554 | .noty_layout .noty_theme__nest.noty_bar:nth-child(3) { 555 | position: absolute; 556 | top: 0; 557 | margin-top: 8px; 558 | margin-right: -8px; 559 | margin-left: 8px; 560 | z-index: 3; 561 | width: 100%; } 562 | 563 | .noty_layout .noty_theme__nest.noty_bar:nth-child(4) { 564 | position: absolute; 565 | top: 0; 566 | margin-top: 12px; 567 | margin-right: -12px; 568 | margin-left: 12px; 569 | z-index: 2; 570 | width: 100%; } 571 | 572 | .noty_layout .noty_theme__nest.noty_bar:nth-child(5) { 573 | position: absolute; 574 | top: 0; 575 | margin-top: 16px; 576 | margin-right: -16px; 577 | margin-left: 16px; 578 | z-index: 1; 579 | width: 100%; } 580 | 581 | .noty_layout .noty_theme__nest.noty_bar:nth-child(n+6) { 582 | position: absolute; 583 | top: 0; 584 | margin-top: 20px; 585 | margin-right: -20px; 586 | margin-left: 20px; 587 | z-index: -1; 588 | width: 100%; } 589 | 590 | #noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(2), 591 | #noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(2) { 592 | margin-top: 4px; 593 | margin-left: -4px; 594 | margin-right: 4px; } 595 | 596 | #noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(3), 597 | #noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(3) { 598 | margin-top: 8px; 599 | margin-left: -8px; 600 | margin-right: 8px; } 601 | 602 | #noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(4), 603 | #noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(4) { 604 | margin-top: 12px; 605 | margin-left: -12px; 606 | margin-right: 12px; } 607 | 608 | #noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(5), 609 | #noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(5) { 610 | margin-top: 16px; 611 | margin-left: -16px; 612 | margin-right: 16px; } 613 | 614 | #noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(n+6), 615 | #noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(n+6) { 616 | margin-top: 20px; 617 | margin-left: -20px; 618 | margin-right: 20px; } 619 | 620 | .noty_theme__nest.noty_type__alert, 621 | .noty_theme__nest.noty_type__notification { 622 | background-color: #073B4C; 623 | color: #fff; } 624 | .noty_theme__nest.noty_type__alert .noty_progressbar, 625 | .noty_theme__nest.noty_type__notification .noty_progressbar { 626 | background-color: #fff; } 627 | 628 | .noty_theme__nest.noty_type__warning { 629 | background-color: #FFD166; 630 | color: #fff; } 631 | 632 | .noty_theme__nest.noty_type__error { 633 | background-color: #EF476F; 634 | color: #fff; } 635 | .noty_theme__nest.noty_type__error .noty_progressbar { 636 | opacity: .4; } 637 | 638 | .noty_theme__nest.noty_type__info, 639 | .noty_theme__nest.noty_type__information { 640 | background-color: #118AB2; 641 | color: #fff; } 642 | .noty_theme__nest.noty_type__info .noty_progressbar, 643 | .noty_theme__nest.noty_type__information .noty_progressbar { 644 | opacity: .6; } 645 | 646 | .noty_theme__nest.noty_type__success { 647 | background-color: #06D6A0; 648 | color: #fff; } 649 | 650 | /*# sourceMappingURL=noty.css.map*/ -------------------------------------------------------------------------------- /pNotify/html/noty.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(); 4 | else if(typeof define === 'function' && define.amd) 5 | define("Noty", [], factory); 6 | else if(typeof exports === 'object') 7 | exports["Noty"] = factory(); 8 | else 9 | root["Noty"] = factory(); 10 | })(this, function() { 11 | return /******/ (function(modules) { // webpackBootstrap 12 | /******/ // The module cache 13 | /******/ var installedModules = {}; 14 | /******/ 15 | /******/ // The require function 16 | /******/ function __webpack_require__(moduleId) { 17 | /******/ 18 | /******/ // Check if module is in cache 19 | /******/ if(installedModules[moduleId]) { 20 | /******/ return installedModules[moduleId].exports; 21 | /******/ } 22 | /******/ // Create a new module (and put it into the cache) 23 | /******/ var module = installedModules[moduleId] = { 24 | /******/ i: moduleId, 25 | /******/ l: false, 26 | /******/ exports: {} 27 | /******/ }; 28 | /******/ 29 | /******/ // Execute the module function 30 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31 | /******/ 32 | /******/ // Flag the module as loaded 33 | /******/ module.l = true; 34 | /******/ 35 | /******/ // Return the exports of the module 36 | /******/ return module.exports; 37 | /******/ } 38 | /******/ 39 | /******/ 40 | /******/ // expose the modules object (__webpack_modules__) 41 | /******/ __webpack_require__.m = modules; 42 | /******/ 43 | /******/ // expose the module cache 44 | /******/ __webpack_require__.c = installedModules; 45 | /******/ 46 | /******/ // identity function for calling harmony imports with the correct context 47 | /******/ __webpack_require__.i = function(value) { return value; }; 48 | /******/ 49 | /******/ // define getter function for harmony exports 50 | /******/ __webpack_require__.d = function(exports, name, getter) { 51 | /******/ if(!__webpack_require__.o(exports, name)) { 52 | /******/ Object.defineProperty(exports, name, { 53 | /******/ configurable: false, 54 | /******/ enumerable: true, 55 | /******/ get: getter 56 | /******/ }); 57 | /******/ } 58 | /******/ }; 59 | /******/ 60 | /******/ // getDefaultExport function for compatibility with non-harmony modules 61 | /******/ __webpack_require__.n = function(module) { 62 | /******/ var getter = module && module.__esModule ? 63 | /******/ function getDefault() { return module['default']; } : 64 | /******/ function getModuleExports() { return module; }; 65 | /******/ __webpack_require__.d(getter, 'a', getter); 66 | /******/ return getter; 67 | /******/ }; 68 | /******/ 69 | /******/ // Object.prototype.hasOwnProperty.call 70 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 71 | /******/ 72 | /******/ // __webpack_public_path__ 73 | /******/ __webpack_require__.p = ""; 74 | /******/ 75 | /******/ // Load entry module and return exports 76 | /******/ return __webpack_require__(__webpack_require__.s = 6); 77 | /******/ }) 78 | /************************************************************************/ 79 | /******/ ([ 80 | /* 0 */ 81 | /***/ (function(module, exports, __webpack_require__) { 82 | 83 | "use strict"; 84 | 85 | 86 | Object.defineProperty(exports, "__esModule", { 87 | value: true 88 | }); 89 | exports.css = exports.deepExtend = exports.animationEndEvents = undefined; 90 | 91 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 92 | 93 | exports.inArray = inArray; 94 | exports.stopPropagation = stopPropagation; 95 | exports.generateID = generateID; 96 | exports.outerHeight = outerHeight; 97 | exports.addListener = addListener; 98 | exports.hasClass = hasClass; 99 | exports.addClass = addClass; 100 | exports.removeClass = removeClass; 101 | exports.remove = remove; 102 | exports.classList = classList; 103 | exports.visibilityChangeFlow = visibilityChangeFlow; 104 | exports.createAudioElements = createAudioElements; 105 | 106 | var _api = __webpack_require__(1); 107 | 108 | var API = _interopRequireWildcard(_api); 109 | 110 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 111 | 112 | var animationEndEvents = exports.animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; 113 | 114 | function inArray(needle, haystack, argStrict) { 115 | var key = void 0; 116 | var strict = !!argStrict; 117 | 118 | if (strict) { 119 | for (key in haystack) { 120 | if (haystack.hasOwnProperty(key) && haystack[key] === needle) { 121 | return true; 122 | } 123 | } 124 | } else { 125 | for (key in haystack) { 126 | if (haystack.hasOwnProperty(key) && haystack[key] === needle) { 127 | return true; 128 | } 129 | } 130 | } 131 | return false; 132 | } 133 | 134 | function stopPropagation(evt) { 135 | evt = evt || window.event; 136 | 137 | if (typeof evt.stopPropagation !== 'undefined') { 138 | evt.stopPropagation(); 139 | } else { 140 | evt.cancelBubble = true; 141 | } 142 | } 143 | 144 | var deepExtend = exports.deepExtend = function deepExtend(out) { 145 | out = out || {}; 146 | 147 | for (var i = 1; i < arguments.length; i++) { 148 | var obj = arguments[i]; 149 | 150 | if (!obj) continue; 151 | 152 | for (var key in obj) { 153 | if (obj.hasOwnProperty(key)) { 154 | if (Array.isArray(obj[key])) { 155 | out[key] = obj[key]; 156 | } else if (_typeof(obj[key]) === 'object' && obj[key] !== null) { 157 | out[key] = deepExtend(out[key], obj[key]); 158 | } else { 159 | out[key] = obj[key]; 160 | } 161 | } 162 | } 163 | } 164 | 165 | return out; 166 | }; 167 | 168 | function generateID() { 169 | var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 170 | 171 | var id = 'noty_' + prefix + '_'; 172 | 173 | id += 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 174 | var r = Math.random() * 16 | 0; 175 | var v = c === 'x' ? r : r & 0x3 | 0x8; 176 | return v.toString(16); 177 | }); 178 | 179 | return id; 180 | } 181 | 182 | function outerHeight(el) { 183 | var height = el.offsetHeight; 184 | var style = window.getComputedStyle(el); 185 | 186 | height += parseInt(style.marginTop) + parseInt(style.marginBottom); 187 | return height; 188 | } 189 | 190 | var css = exports.css = function () { 191 | var cssPrefixes = ['Webkit', 'O', 'Moz', 'ms']; 192 | var cssProps = {}; 193 | 194 | function camelCase(string) { 195 | return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function (match, letter) { 196 | return letter.toUpperCase(); 197 | }); 198 | } 199 | 200 | function getVendorProp(name) { 201 | var style = document.body.style; 202 | if (name in style) return name; 203 | 204 | var i = cssPrefixes.length; 205 | var capName = name.charAt(0).toUpperCase() + name.slice(1); 206 | var vendorName = void 0; 207 | 208 | while (i--) { 209 | vendorName = cssPrefixes[i] + capName; 210 | if (vendorName in style) return vendorName; 211 | } 212 | 213 | return name; 214 | } 215 | 216 | function getStyleProp(name) { 217 | name = camelCase(name); 218 | return cssProps[name] || (cssProps[name] = getVendorProp(name)); 219 | } 220 | 221 | function applyCss(element, prop, value) { 222 | prop = getStyleProp(prop); 223 | element.style[prop] = value; 224 | } 225 | 226 | return function (element, properties) { 227 | var args = arguments; 228 | var prop = void 0; 229 | var value = void 0; 230 | 231 | if (args.length === 2) { 232 | for (prop in properties) { 233 | if (properties.hasOwnProperty(prop)) { 234 | value = properties[prop]; 235 | if (value !== undefined && properties.hasOwnProperty(prop)) { 236 | applyCss(element, prop, value); 237 | } 238 | } 239 | } 240 | } else { 241 | applyCss(element, args[1], args[2]); 242 | } 243 | }; 244 | }(); 245 | 246 | function addListener(el, events, cb) { 247 | var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 248 | 249 | events = events.split(' '); 250 | for (var i = 0; i < events.length; i++) { 251 | if (document.addEventListener) { 252 | el.addEventListener(events[i], cb, useCapture); 253 | } else if (document.attachEvent) { 254 | el.attachEvent('on' + events[i], cb); 255 | } 256 | } 257 | } 258 | 259 | function hasClass(element, name) { 260 | var list = typeof element === 'string' ? element : classList(element); 261 | return list.indexOf(' ' + name + ' ') >= 0; 262 | } 263 | 264 | function addClass(element, name) { 265 | var oldList = classList(element); 266 | var newList = oldList + name; 267 | 268 | if (hasClass(oldList, name)) return; 269 | 270 | // Trim the opening space. 271 | element.className = newList.substring(1); 272 | } 273 | 274 | function removeClass(element, name) { 275 | var oldList = classList(element); 276 | var newList = void 0; 277 | 278 | if (!hasClass(element, name)) return; 279 | 280 | // Replace the class name. 281 | newList = oldList.replace(' ' + name + ' ', ' '); 282 | 283 | // Trim the opening and closing spaces. 284 | element.className = newList.substring(1, newList.length - 1); 285 | } 286 | 287 | function remove(element) { 288 | if (element.parentNode) { 289 | element.parentNode.removeChild(element); 290 | } 291 | } 292 | 293 | function classList(element) { 294 | return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' '); 295 | } 296 | 297 | function visibilityChangeFlow() { 298 | var hidden = void 0; 299 | var visibilityChange = void 0; 300 | if (typeof document.hidden !== 'undefined') { 301 | // Opera 12.10 and Firefox 18 and later support 302 | hidden = 'hidden'; 303 | visibilityChange = 'visibilitychange'; 304 | } else if (typeof document.msHidden !== 'undefined') { 305 | hidden = 'msHidden'; 306 | visibilityChange = 'msvisibilitychange'; 307 | } else if (typeof document.webkitHidden !== 'undefined') { 308 | hidden = 'webkitHidden'; 309 | visibilityChange = 'webkitvisibilitychange'; 310 | } 311 | 312 | function onVisibilityChange() { 313 | API.PageHidden = document[hidden]; 314 | handleVisibilityChange(); 315 | } 316 | 317 | function onBlur() { 318 | API.PageHidden = true; 319 | handleVisibilityChange(); 320 | } 321 | 322 | function onFocus() { 323 | API.PageHidden = false; 324 | handleVisibilityChange(); 325 | } 326 | 327 | function handleVisibilityChange() { 328 | if (API.PageHidden) stopAll();else resumeAll(); 329 | } 330 | 331 | function stopAll() { 332 | setTimeout(function () { 333 | Object.keys(API.Store).forEach(function (id) { 334 | if (API.Store.hasOwnProperty(id)) { 335 | if (API.Store[id].options.visibilityControl) { 336 | API.Store[id].stop(); 337 | } 338 | } 339 | }); 340 | }, 100); 341 | } 342 | 343 | function resumeAll() { 344 | setTimeout(function () { 345 | Object.keys(API.Store).forEach(function (id) { 346 | if (API.Store.hasOwnProperty(id)) { 347 | if (API.Store[id].options.visibilityControl) { 348 | API.Store[id].resume(); 349 | } 350 | } 351 | }); 352 | API.queueRenderAll(); 353 | }, 100); 354 | } 355 | 356 | addListener(document, visibilityChange, onVisibilityChange); 357 | addListener(window, 'blur', onBlur); 358 | addListener(window, 'focus', onFocus); 359 | } 360 | 361 | function createAudioElements(ref) { 362 | if (ref.hasSound) { 363 | var audioElement = document.createElement('audio'); 364 | 365 | ref.options.sounds.sources.forEach(function (s) { 366 | var source = document.createElement('source'); 367 | source.src = s; 368 | source.type = 'audio/' + getExtension(s); 369 | audioElement.appendChild(source); 370 | }); 371 | 372 | if (ref.barDom) { 373 | ref.barDom.appendChild(audioElement); 374 | } else { 375 | document.querySelector('body').appendChild(audioElement); 376 | } 377 | 378 | audioElement.volume = ref.options.sounds.volume; 379 | 380 | if (!ref.soundPlayed) { 381 | audioElement.play(); 382 | ref.soundPlayed = true; 383 | } 384 | 385 | audioElement.onended = function () { 386 | remove(audioElement); 387 | }; 388 | } 389 | } 390 | 391 | function getExtension(fileName) { 392 | return fileName.match(/\.([^.]+)$/)[1]; 393 | } 394 | 395 | /***/ }), 396 | /* 1 */ 397 | /***/ (function(module, exports, __webpack_require__) { 398 | 399 | "use strict"; 400 | 401 | 402 | Object.defineProperty(exports, "__esModule", { 403 | value: true 404 | }); 405 | exports.Defaults = exports.Store = exports.Queues = exports.DefaultMaxVisible = exports.docTitle = exports.DocModalCount = exports.PageHidden = undefined; 406 | exports.getQueueCounts = getQueueCounts; 407 | exports.addToQueue = addToQueue; 408 | exports.removeFromQueue = removeFromQueue; 409 | exports.queueRender = queueRender; 410 | exports.queueRenderAll = queueRenderAll; 411 | exports.ghostFix = ghostFix; 412 | exports.build = build; 413 | exports.hasButtons = hasButtons; 414 | exports.handleModal = handleModal; 415 | exports.handleModalClose = handleModalClose; 416 | exports.queueClose = queueClose; 417 | exports.dequeueClose = dequeueClose; 418 | exports.fire = fire; 419 | exports.openFlow = openFlow; 420 | exports.closeFlow = closeFlow; 421 | 422 | var _utils = __webpack_require__(0); 423 | 424 | var Utils = _interopRequireWildcard(_utils); 425 | 426 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 427 | 428 | var PageHidden = exports.PageHidden = false; 429 | var DocModalCount = exports.DocModalCount = 0; 430 | 431 | var DocTitleProps = { 432 | originalTitle: null, 433 | count: 0, 434 | changed: false, 435 | timer: -1 436 | }; 437 | 438 | var docTitle = exports.docTitle = { 439 | increment: function increment() { 440 | DocTitleProps.count++; 441 | 442 | docTitle._update(); 443 | }, 444 | 445 | decrement: function decrement() { 446 | DocTitleProps.count--; 447 | 448 | if (DocTitleProps.count <= 0) { 449 | docTitle._clear(); 450 | return; 451 | } 452 | 453 | docTitle._update(); 454 | }, 455 | 456 | _update: function _update() { 457 | var title = document.title; 458 | 459 | if (!DocTitleProps.changed) { 460 | DocTitleProps.originalTitle = title; 461 | document.title = '(' + DocTitleProps.count + ') ' + title; 462 | DocTitleProps.changed = true; 463 | } else { 464 | document.title = '(' + DocTitleProps.count + ') ' + DocTitleProps.originalTitle; 465 | } 466 | }, 467 | 468 | _clear: function _clear() { 469 | if (DocTitleProps.changed) { 470 | DocTitleProps.count = 0; 471 | document.title = DocTitleProps.originalTitle; 472 | DocTitleProps.changed = false; 473 | } 474 | } 475 | }; 476 | 477 | var DefaultMaxVisible = exports.DefaultMaxVisible = 5; 478 | 479 | var Queues = exports.Queues = { 480 | global: { 481 | maxVisible: DefaultMaxVisible, 482 | queue: [] 483 | } 484 | }; 485 | 486 | var Store = exports.Store = {}; 487 | 488 | var Defaults = exports.Defaults = { 489 | type: 'alert', 490 | layout: 'topRight', 491 | theme: 'mint', 492 | text: '', 493 | timeout: false, 494 | progressBar: true, 495 | closeWith: ['click'], 496 | animation: { 497 | open: 'noty_effects_open', 498 | close: 'noty_effects_close' 499 | }, 500 | id: false, 501 | force: false, 502 | killer: false, 503 | queue: 'global', 504 | container: false, 505 | buttons: [], 506 | callbacks: { 507 | beforeShow: null, 508 | onShow: null, 509 | afterShow: null, 510 | onClose: null, 511 | afterClose: null, 512 | onHover: null, 513 | onTemplate: null 514 | }, 515 | sounds: { 516 | sources: [], 517 | volume: 1, 518 | conditions: [] 519 | }, 520 | titleCount: { 521 | conditions: [] 522 | }, 523 | modal: false, 524 | visibilityControl: true 525 | }; 526 | 527 | /** 528 | * @param {string} queueName 529 | * @return {object} 530 | */ 531 | function getQueueCounts() { 532 | var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'global'; 533 | 534 | var count = 0; 535 | var max = DefaultMaxVisible; 536 | 537 | if (Queues.hasOwnProperty(queueName)) { 538 | max = Queues[queueName].maxVisible; 539 | Object.keys(Store).forEach(function (i) { 540 | if (Store[i].options.queue === queueName && !Store[i].closed) count++; 541 | }); 542 | } 543 | 544 | return { 545 | current: count, 546 | maxVisible: max 547 | }; 548 | } 549 | 550 | /** 551 | * @param {Noty} ref 552 | * @return {void} 553 | */ 554 | function addToQueue(ref) { 555 | if (!Queues.hasOwnProperty(ref.options.queue)) { 556 | Queues[ref.options.queue] = { maxVisible: DefaultMaxVisible, queue: [] }; 557 | } 558 | 559 | Queues[ref.options.queue].queue.push(ref); 560 | } 561 | 562 | /** 563 | * @param {Noty} ref 564 | * @return {void} 565 | */ 566 | function removeFromQueue(ref) { 567 | if (Queues.hasOwnProperty(ref.options.queue)) { 568 | var queue = []; 569 | Object.keys(Queues[ref.options.queue].queue).forEach(function (i) { 570 | if (Queues[ref.options.queue].queue[i].id !== ref.id) { 571 | queue.push(Queues[ref.options.queue].queue[i]); 572 | } 573 | }); 574 | Queues[ref.options.queue].queue = queue; 575 | } 576 | } 577 | 578 | /** 579 | * @param {string} queueName 580 | * @return {void} 581 | */ 582 | function queueRender() { 583 | var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'global'; 584 | 585 | if (Queues.hasOwnProperty(queueName)) { 586 | var noty = Queues[queueName].queue.shift(); 587 | 588 | if (noty) noty.show(); 589 | } 590 | } 591 | 592 | /** 593 | * @return {void} 594 | */ 595 | function queueRenderAll() { 596 | Object.keys(Queues).forEach(function (queueName) { 597 | queueRender(queueName); 598 | }); 599 | } 600 | 601 | /** 602 | * @param {Noty} ref 603 | * @return {void} 604 | */ 605 | function ghostFix(ref) { 606 | var ghostID = Utils.generateID('ghost'); 607 | var ghost = document.createElement('div'); 608 | ghost.setAttribute('id', ghostID); 609 | Utils.css(ghost, { 610 | height: Utils.outerHeight(ref.barDom) + 'px' 611 | }); 612 | 613 | ref.barDom.insertAdjacentHTML('afterend', ghost.outerHTML); 614 | 615 | Utils.remove(ref.barDom); 616 | ghost = document.getElementById(ghostID); 617 | Utils.addClass(ghost, 'noty_fix_effects_height'); 618 | Utils.addListener(ghost, Utils.animationEndEvents, function () { 619 | Utils.remove(ghost); 620 | }); 621 | } 622 | 623 | /** 624 | * @param {Noty} ref 625 | * @return {void} 626 | */ 627 | function build(ref) { 628 | findOrCreateContainer(ref); 629 | 630 | var markup = '
' + ref.options.text + '
' + buildButtons(ref) + (ref.options.progressBar ? '
' : ''); 631 | 632 | ref.barDom = document.createElement('div'); 633 | ref.barDom.setAttribute('id', ref.id); 634 | Utils.addClass(ref.barDom, 'noty_bar noty_type__' + ref.options.type + ' noty_theme__' + ref.options.theme); 635 | 636 | ref.barDom.innerHTML = markup; 637 | 638 | fire(ref, 'onTemplate'); 639 | } 640 | 641 | /** 642 | * @param {Noty} ref 643 | * @return {boolean} 644 | */ 645 | function hasButtons(ref) { 646 | return !!(ref.options.buttons && Object.keys(ref.options.buttons).length); 647 | } 648 | 649 | /** 650 | * @param {Noty} ref 651 | * @return {string} 652 | */ 653 | function buildButtons(ref) { 654 | if (hasButtons(ref)) { 655 | var buttons = document.createElement('div'); 656 | Utils.addClass(buttons, 'noty_buttons'); 657 | 658 | Object.keys(ref.options.buttons).forEach(function (key) { 659 | buttons.appendChild(ref.options.buttons[key].dom); 660 | }); 661 | 662 | ref.options.buttons.forEach(function (btn) { 663 | buttons.appendChild(btn.dom); 664 | }); 665 | return buttons.outerHTML; 666 | } 667 | return ''; 668 | } 669 | 670 | /** 671 | * @param {Noty} ref 672 | * @return {void} 673 | */ 674 | function handleModal(ref) { 675 | if (ref.options.modal) { 676 | if (DocModalCount === 0) { 677 | createModal(ref); 678 | } 679 | 680 | exports.DocModalCount = DocModalCount += 1; 681 | } 682 | } 683 | 684 | /** 685 | * @param {Noty} ref 686 | * @return {void} 687 | */ 688 | function handleModalClose(ref) { 689 | if (ref.options.modal && DocModalCount > 0) { 690 | exports.DocModalCount = DocModalCount -= 1; 691 | 692 | if (DocModalCount <= 0) { 693 | var modal = document.querySelector('.noty_modal'); 694 | 695 | if (modal) { 696 | Utils.removeClass(modal, 'noty_modal_open'); 697 | Utils.addClass(modal, 'noty_modal_close'); 698 | Utils.addListener(modal, Utils.animationEndEvents, function () { 699 | Utils.remove(modal); 700 | }); 701 | } 702 | } 703 | } 704 | } 705 | 706 | /** 707 | * @return {void} 708 | */ 709 | function createModal() { 710 | var body = document.querySelector('body'); 711 | var modal = document.createElement('div'); 712 | Utils.addClass(modal, 'noty_modal'); 713 | body.insertBefore(modal, body.firstChild); 714 | Utils.addClass(modal, 'noty_modal_open'); 715 | 716 | Utils.addListener(modal, Utils.animationEndEvents, function () { 717 | Utils.removeClass(modal, 'noty_modal_open'); 718 | }); 719 | } 720 | 721 | /** 722 | * @param {Noty} ref 723 | * @return {void} 724 | */ 725 | function findOrCreateContainer(ref) { 726 | if (ref.options.container) { 727 | ref.layoutDom = document.querySelector(ref.options.container); 728 | return; 729 | } 730 | 731 | var layoutID = 'noty_layout__' + ref.options.layout; 732 | ref.layoutDom = document.querySelector('div#' + layoutID); 733 | 734 | if (!ref.layoutDom) { 735 | ref.layoutDom = document.createElement('div'); 736 | ref.layoutDom.setAttribute('id', layoutID); 737 | Utils.addClass(ref.layoutDom, 'noty_layout'); 738 | document.querySelector('body').appendChild(ref.layoutDom); 739 | } 740 | } 741 | 742 | /** 743 | * @param {Noty} ref 744 | * @return {void} 745 | */ 746 | function queueClose(ref) { 747 | if (ref.options.timeout) { 748 | if (ref.options.progressBar && ref.progressDom) { 749 | Utils.css(ref.progressDom, { 750 | transition: 'width ' + ref.options.timeout + 'ms linear', 751 | width: '0%' 752 | }); 753 | } 754 | 755 | clearTimeout(ref.closeTimer); 756 | 757 | ref.closeTimer = setTimeout(function () { 758 | ref.close(); 759 | }, ref.options.timeout); 760 | } 761 | } 762 | 763 | /** 764 | * @param {Noty} ref 765 | * @return {void} 766 | */ 767 | function dequeueClose(ref) { 768 | if (ref.options.timeout && ref.closeTimer) { 769 | clearTimeout(ref.closeTimer); 770 | ref.closeTimer = -1; 771 | 772 | if (ref.options.progressBar && ref.progressDom) { 773 | Utils.css(ref.progressDom, { 774 | transition: 'width 0ms linear', 775 | width: '100%' 776 | }); 777 | } 778 | } 779 | } 780 | 781 | /** 782 | * @param {Noty} ref 783 | * @param {string} eventName 784 | * @return {void} 785 | */ 786 | function fire(ref, eventName) { 787 | if (ref.listeners.hasOwnProperty(eventName)) { 788 | ref.listeners[eventName].forEach(function (cb) { 789 | if (typeof cb === 'function') { 790 | cb.apply(ref); 791 | } 792 | }); 793 | } 794 | } 795 | 796 | /** 797 | * @param {Noty} ref 798 | * @return {void} 799 | */ 800 | function openFlow(ref) { 801 | fire(ref, 'afterShow'); 802 | queueClose(ref); 803 | 804 | Utils.addListener(ref.barDom, 'mouseenter', function () { 805 | dequeueClose(ref); 806 | }); 807 | 808 | Utils.addListener(ref.barDom, 'mouseleave', function () { 809 | queueClose(ref); 810 | }); 811 | } 812 | 813 | /** 814 | * @param {Noty} ref 815 | * @return {void} 816 | */ 817 | function closeFlow(ref) { 818 | delete Store[ref.id]; 819 | ref.closing = false; 820 | fire(ref, 'afterClose'); 821 | 822 | Utils.remove(ref.barDom); 823 | 824 | if (ref.layoutDom.querySelectorAll('.noty_bar').length === 0 && !ref.options.container) { 825 | Utils.remove(ref.layoutDom); 826 | } 827 | 828 | if (Utils.inArray('docVisible', ref.options.titleCount.conditions) || Utils.inArray('docHidden', ref.options.titleCount.conditions)) { 829 | docTitle.decrement(); 830 | } 831 | 832 | queueRender(ref.options.queue); 833 | } 834 | 835 | /***/ }), 836 | /* 2 */ 837 | /***/ (function(module, exports, __webpack_require__) { 838 | 839 | "use strict"; 840 | 841 | 842 | Object.defineProperty(exports, "__esModule", { 843 | value: true 844 | }); 845 | exports.NotyButton = undefined; 846 | 847 | var _utils = __webpack_require__(0); 848 | 849 | var Utils = _interopRequireWildcard(_utils); 850 | 851 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 852 | 853 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 854 | 855 | var NotyButton = exports.NotyButton = function NotyButton(html, classes, cb) { 856 | var _this = this; 857 | 858 | var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; 859 | 860 | _classCallCheck(this, NotyButton); 861 | 862 | this.dom = document.createElement('button'); 863 | this.dom.innerHTML = html; 864 | this.id = attributes.id = attributes.id || Utils.generateID('button'); 865 | this.cb = cb; 866 | Object.keys(attributes).forEach(function (propertyName) { 867 | _this.dom.setAttribute(propertyName, attributes[propertyName]); 868 | }); 869 | Utils.addClass(this.dom, classes || 'noty_btn'); 870 | 871 | return this; 872 | }; 873 | 874 | /***/ }), 875 | /* 3 */ 876 | /***/ (function(module, exports, __webpack_require__) { 877 | 878 | "use strict"; 879 | 880 | 881 | Object.defineProperty(exports, "__esModule", { 882 | value: true 883 | }); 884 | 885 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 886 | 887 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 888 | 889 | var Push = exports.Push = function () { 890 | function Push() { 891 | var workerPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/service-worker.js'; 892 | 893 | _classCallCheck(this, Push); 894 | 895 | this.subData = {}; 896 | this.workerPath = workerPath; 897 | this.listeners = { 898 | onPermissionGranted: [], 899 | onPermissionDenied: [], 900 | onSubscriptionSuccess: [], 901 | onSubscriptionCancel: [], 902 | onWorkerError: [], 903 | onWorkerSuccess: [], 904 | onWorkerNotSupported: [] 905 | }; 906 | return this; 907 | } 908 | 909 | /** 910 | * @param {string} eventName 911 | * @param {function} cb 912 | * @return {Push} 913 | */ 914 | 915 | 916 | _createClass(Push, [{ 917 | key: 'on', 918 | value: function on(eventName) { 919 | var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; 920 | 921 | if (typeof cb === 'function' && this.listeners.hasOwnProperty(eventName)) { 922 | this.listeners[eventName].push(cb); 923 | } 924 | 925 | return this; 926 | } 927 | }, { 928 | key: 'fire', 929 | value: function fire(eventName) { 930 | var _this = this; 931 | 932 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 933 | 934 | if (this.listeners.hasOwnProperty(eventName)) { 935 | this.listeners[eventName].forEach(function (cb) { 936 | if (typeof cb === 'function') { 937 | cb.apply(_this, params); 938 | } 939 | }); 940 | } 941 | } 942 | }, { 943 | key: 'create', 944 | value: function create() { 945 | console.log('NOT IMPLEMENTED YET'); 946 | } 947 | 948 | /** 949 | * @return {boolean} 950 | */ 951 | 952 | }, { 953 | key: 'isSupported', 954 | value: function isSupported() { 955 | var result = false; 956 | 957 | try { 958 | result = window.Notification || window.webkitNotifications || navigator.mozNotification || window.external && window.external.msIsSiteMode() !== undefined; 959 | } catch (e) {} 960 | 961 | return result; 962 | } 963 | 964 | /** 965 | * @return {string} 966 | */ 967 | 968 | }, { 969 | key: 'getPermissionStatus', 970 | value: function getPermissionStatus() { 971 | var perm = 'default'; 972 | 973 | if (window.Notification && window.Notification.permissionLevel) { 974 | perm = window.Notification.permissionLevel; 975 | } else if (window.webkitNotifications && window.webkitNotifications.checkPermission) { 976 | switch (window.webkitNotifications.checkPermission()) { 977 | case 1: 978 | perm = 'default'; 979 | break; 980 | case 0: 981 | perm = 'granted'; 982 | break; 983 | default: 984 | perm = 'denied'; 985 | } 986 | } else if (window.Notification && window.Notification.permission) { 987 | perm = window.Notification.permission; 988 | } else if (navigator.mozNotification) { 989 | perm = 'granted'; 990 | } else if (window.external && window.external.msIsSiteMode() !== undefined) { 991 | perm = window.external.msIsSiteMode() ? 'granted' : 'default'; 992 | } 993 | 994 | return perm.toString().toLowerCase(); 995 | } 996 | 997 | /** 998 | * @return {string} 999 | */ 1000 | 1001 | }, { 1002 | key: 'getEndpoint', 1003 | value: function getEndpoint(subscription) { 1004 | var endpoint = subscription.endpoint; 1005 | var subscriptionId = subscription.subscriptionId; 1006 | 1007 | // fix for Chrome < 45 1008 | if (subscriptionId && endpoint.indexOf(subscriptionId) === -1) { 1009 | endpoint += '/' + subscriptionId; 1010 | } 1011 | 1012 | return endpoint; 1013 | } 1014 | 1015 | /** 1016 | * @return {boolean} 1017 | */ 1018 | 1019 | }, { 1020 | key: 'isSWRegistered', 1021 | value: function isSWRegistered() { 1022 | try { 1023 | return navigator.serviceWorker.controller.state === 'activated'; 1024 | } catch (e) { 1025 | return false; 1026 | } 1027 | } 1028 | 1029 | /** 1030 | * @return {void} 1031 | */ 1032 | 1033 | }, { 1034 | key: 'unregisterWorker', 1035 | value: function unregisterWorker() { 1036 | var self = this; 1037 | if ('serviceWorker' in navigator) { 1038 | navigator.serviceWorker.getRegistrations().then(function (registrations) { 1039 | var _iteratorNormalCompletion = true; 1040 | var _didIteratorError = false; 1041 | var _iteratorError = undefined; 1042 | 1043 | try { 1044 | for (var _iterator = registrations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { 1045 | var registration = _step.value; 1046 | 1047 | registration.unregister(); 1048 | self.fire('onSubscriptionCancel'); 1049 | } 1050 | } catch (err) { 1051 | _didIteratorError = true; 1052 | _iteratorError = err; 1053 | } finally { 1054 | try { 1055 | if (!_iteratorNormalCompletion && _iterator.return) { 1056 | _iterator.return(); 1057 | } 1058 | } finally { 1059 | if (_didIteratorError) { 1060 | throw _iteratorError; 1061 | } 1062 | } 1063 | } 1064 | }); 1065 | } 1066 | } 1067 | 1068 | /** 1069 | * @return {void} 1070 | */ 1071 | 1072 | }, { 1073 | key: 'requestSubscription', 1074 | value: function requestSubscription() { 1075 | var _this2 = this; 1076 | 1077 | var userVisibleOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; 1078 | 1079 | var self = this; 1080 | var current = this.getPermissionStatus(); 1081 | var cb = function cb(result) { 1082 | if (result === 'granted') { 1083 | _this2.fire('onPermissionGranted'); 1084 | 1085 | if ('serviceWorker' in navigator) { 1086 | navigator.serviceWorker.register(_this2.workerPath).then(function () { 1087 | navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) { 1088 | self.fire('onWorkerSuccess'); 1089 | serviceWorkerRegistration.pushManager.subscribe({ 1090 | userVisibleOnly: userVisibleOnly 1091 | }).then(function (subscription) { 1092 | var key = subscription.getKey('p256dh'); 1093 | var token = subscription.getKey('auth'); 1094 | 1095 | self.subData = { 1096 | endpoint: self.getEndpoint(subscription), 1097 | p256dh: key ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : null, 1098 | auth: token ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(token))) : null 1099 | }; 1100 | 1101 | self.fire('onSubscriptionSuccess', [self.subData]); 1102 | }).catch(function (err) { 1103 | self.fire('onWorkerError', [err]); 1104 | }); 1105 | }); 1106 | }); 1107 | } else { 1108 | self.fire('onWorkerNotSupported'); 1109 | } 1110 | } else if (result === 'denied') { 1111 | _this2.fire('onPermissionDenied'); 1112 | _this2.unregisterWorker(); 1113 | } 1114 | }; 1115 | 1116 | if (current === 'default') { 1117 | if (window.Notification && window.Notification.requestPermission) { 1118 | window.Notification.requestPermission(cb); 1119 | } else if (window.webkitNotifications && window.webkitNotifications.checkPermission) { 1120 | window.webkitNotifications.requestPermission(cb); 1121 | } 1122 | } else { 1123 | cb(current); 1124 | } 1125 | } 1126 | }]); 1127 | 1128 | return Push; 1129 | }(); 1130 | 1131 | /***/ }), 1132 | /* 4 */ 1133 | /***/ (function(module, exports, __webpack_require__) { 1134 | 1135 | /* WEBPACK VAR INJECTION */(function(process, global) {var require;/*! 1136 | * @overview es6-promise - a tiny implementation of Promises/A+. 1137 | * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) 1138 | * @license Licensed under MIT license 1139 | * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE 1140 | * @version 4.1.0 1141 | */ 1142 | 1143 | (function (global, factory) { 1144 | true ? module.exports = factory() : 1145 | typeof define === 'function' && define.amd ? define(factory) : 1146 | (global.ES6Promise = factory()); 1147 | }(this, (function () { 'use strict'; 1148 | 1149 | function objectOrFunction(x) { 1150 | return typeof x === 'function' || typeof x === 'object' && x !== null; 1151 | } 1152 | 1153 | function isFunction(x) { 1154 | return typeof x === 'function'; 1155 | } 1156 | 1157 | var _isArray = undefined; 1158 | if (!Array.isArray) { 1159 | _isArray = function (x) { 1160 | return Object.prototype.toString.call(x) === '[object Array]'; 1161 | }; 1162 | } else { 1163 | _isArray = Array.isArray; 1164 | } 1165 | 1166 | var isArray = _isArray; 1167 | 1168 | var len = 0; 1169 | var vertxNext = undefined; 1170 | var customSchedulerFn = undefined; 1171 | 1172 | var asap = function asap(callback, arg) { 1173 | queue[len] = callback; 1174 | queue[len + 1] = arg; 1175 | len += 2; 1176 | if (len === 2) { 1177 | // If len is 2, that means that we need to schedule an async flush. 1178 | // If additional callbacks are queued before the queue is flushed, they 1179 | // will be processed by this flush that we are scheduling. 1180 | if (customSchedulerFn) { 1181 | customSchedulerFn(flush); 1182 | } else { 1183 | scheduleFlush(); 1184 | } 1185 | } 1186 | }; 1187 | 1188 | function setScheduler(scheduleFn) { 1189 | customSchedulerFn = scheduleFn; 1190 | } 1191 | 1192 | function setAsap(asapFn) { 1193 | asap = asapFn; 1194 | } 1195 | 1196 | var browserWindow = typeof window !== 'undefined' ? window : undefined; 1197 | var browserGlobal = browserWindow || {}; 1198 | var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; 1199 | var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; 1200 | 1201 | // test for web worker but not in IE10 1202 | var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; 1203 | 1204 | // node 1205 | function useNextTick() { 1206 | // node version 0.10.x displays a deprecation warning when nextTick is used recursively 1207 | // see https://github.com/cujojs/when/issues/410 for details 1208 | return function () { 1209 | return process.nextTick(flush); 1210 | }; 1211 | } 1212 | 1213 | // vertx 1214 | function useVertxTimer() { 1215 | if (typeof vertxNext !== 'undefined') { 1216 | return function () { 1217 | vertxNext(flush); 1218 | }; 1219 | } 1220 | 1221 | return useSetTimeout(); 1222 | } 1223 | 1224 | function useMutationObserver() { 1225 | var iterations = 0; 1226 | var observer = new BrowserMutationObserver(flush); 1227 | var node = document.createTextNode(''); 1228 | observer.observe(node, { characterData: true }); 1229 | 1230 | return function () { 1231 | node.data = iterations = ++iterations % 2; 1232 | }; 1233 | } 1234 | 1235 | // web worker 1236 | function useMessageChannel() { 1237 | var channel = new MessageChannel(); 1238 | channel.port1.onmessage = flush; 1239 | return function () { 1240 | return channel.port2.postMessage(0); 1241 | }; 1242 | } 1243 | 1244 | function useSetTimeout() { 1245 | // Store setTimeout reference so es6-promise will be unaffected by 1246 | // other code modifying setTimeout (like sinon.useFakeTimers()) 1247 | var globalSetTimeout = setTimeout; 1248 | return function () { 1249 | return globalSetTimeout(flush, 1); 1250 | }; 1251 | } 1252 | 1253 | var queue = new Array(1000); 1254 | function flush() { 1255 | for (var i = 0; i < len; i += 2) { 1256 | var callback = queue[i]; 1257 | var arg = queue[i + 1]; 1258 | 1259 | callback(arg); 1260 | 1261 | queue[i] = undefined; 1262 | queue[i + 1] = undefined; 1263 | } 1264 | 1265 | len = 0; 1266 | } 1267 | 1268 | function attemptVertx() { 1269 | try { 1270 | var r = require; 1271 | var vertx = __webpack_require__(9); 1272 | vertxNext = vertx.runOnLoop || vertx.runOnContext; 1273 | return useVertxTimer(); 1274 | } catch (e) { 1275 | return useSetTimeout(); 1276 | } 1277 | } 1278 | 1279 | var scheduleFlush = undefined; 1280 | // Decide what async method to use to triggering processing of queued callbacks: 1281 | if (isNode) { 1282 | scheduleFlush = useNextTick(); 1283 | } else if (BrowserMutationObserver) { 1284 | scheduleFlush = useMutationObserver(); 1285 | } else if (isWorker) { 1286 | scheduleFlush = useMessageChannel(); 1287 | } else if (browserWindow === undefined && "function" === 'function') { 1288 | scheduleFlush = attemptVertx(); 1289 | } else { 1290 | scheduleFlush = useSetTimeout(); 1291 | } 1292 | 1293 | function then(onFulfillment, onRejection) { 1294 | var _arguments = arguments; 1295 | 1296 | var parent = this; 1297 | 1298 | var child = new this.constructor(noop); 1299 | 1300 | if (child[PROMISE_ID] === undefined) { 1301 | makePromise(child); 1302 | } 1303 | 1304 | var _state = parent._state; 1305 | 1306 | if (_state) { 1307 | (function () { 1308 | var callback = _arguments[_state - 1]; 1309 | asap(function () { 1310 | return invokeCallback(_state, child, callback, parent._result); 1311 | }); 1312 | })(); 1313 | } else { 1314 | subscribe(parent, child, onFulfillment, onRejection); 1315 | } 1316 | 1317 | return child; 1318 | } 1319 | 1320 | /** 1321 | `Promise.resolve` returns a promise that will become resolved with the 1322 | passed `value`. It is shorthand for the following: 1323 | 1324 | ```javascript 1325 | let promise = new Promise(function(resolve, reject){ 1326 | resolve(1); 1327 | }); 1328 | 1329 | promise.then(function(value){ 1330 | // value === 1 1331 | }); 1332 | ``` 1333 | 1334 | Instead of writing the above, your code now simply becomes the following: 1335 | 1336 | ```javascript 1337 | let promise = Promise.resolve(1); 1338 | 1339 | promise.then(function(value){ 1340 | // value === 1 1341 | }); 1342 | ``` 1343 | 1344 | @method resolve 1345 | @static 1346 | @param {Any} value value that the returned promise will be resolved with 1347 | Useful for tooling. 1348 | @return {Promise} a promise that will become fulfilled with the given 1349 | `value` 1350 | */ 1351 | function resolve(object) { 1352 | /*jshint validthis:true */ 1353 | var Constructor = this; 1354 | 1355 | if (object && typeof object === 'object' && object.constructor === Constructor) { 1356 | return object; 1357 | } 1358 | 1359 | var promise = new Constructor(noop); 1360 | _resolve(promise, object); 1361 | return promise; 1362 | } 1363 | 1364 | var PROMISE_ID = Math.random().toString(36).substring(16); 1365 | 1366 | function noop() {} 1367 | 1368 | var PENDING = void 0; 1369 | var FULFILLED = 1; 1370 | var REJECTED = 2; 1371 | 1372 | var GET_THEN_ERROR = new ErrorObject(); 1373 | 1374 | function selfFulfillment() { 1375 | return new TypeError("You cannot resolve a promise with itself"); 1376 | } 1377 | 1378 | function cannotReturnOwn() { 1379 | return new TypeError('A promises callback cannot return that same promise.'); 1380 | } 1381 | 1382 | function getThen(promise) { 1383 | try { 1384 | return promise.then; 1385 | } catch (error) { 1386 | GET_THEN_ERROR.error = error; 1387 | return GET_THEN_ERROR; 1388 | } 1389 | } 1390 | 1391 | function tryThen(then, value, fulfillmentHandler, rejectionHandler) { 1392 | try { 1393 | then.call(value, fulfillmentHandler, rejectionHandler); 1394 | } catch (e) { 1395 | return e; 1396 | } 1397 | } 1398 | 1399 | function handleForeignThenable(promise, thenable, then) { 1400 | asap(function (promise) { 1401 | var sealed = false; 1402 | var error = tryThen(then, thenable, function (value) { 1403 | if (sealed) { 1404 | return; 1405 | } 1406 | sealed = true; 1407 | if (thenable !== value) { 1408 | _resolve(promise, value); 1409 | } else { 1410 | fulfill(promise, value); 1411 | } 1412 | }, function (reason) { 1413 | if (sealed) { 1414 | return; 1415 | } 1416 | sealed = true; 1417 | 1418 | _reject(promise, reason); 1419 | }, 'Settle: ' + (promise._label || ' unknown promise')); 1420 | 1421 | if (!sealed && error) { 1422 | sealed = true; 1423 | _reject(promise, error); 1424 | } 1425 | }, promise); 1426 | } 1427 | 1428 | function handleOwnThenable(promise, thenable) { 1429 | if (thenable._state === FULFILLED) { 1430 | fulfill(promise, thenable._result); 1431 | } else if (thenable._state === REJECTED) { 1432 | _reject(promise, thenable._result); 1433 | } else { 1434 | subscribe(thenable, undefined, function (value) { 1435 | return _resolve(promise, value); 1436 | }, function (reason) { 1437 | return _reject(promise, reason); 1438 | }); 1439 | } 1440 | } 1441 | 1442 | function handleMaybeThenable(promise, maybeThenable, then$$) { 1443 | if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { 1444 | handleOwnThenable(promise, maybeThenable); 1445 | } else { 1446 | if (then$$ === GET_THEN_ERROR) { 1447 | _reject(promise, GET_THEN_ERROR.error); 1448 | GET_THEN_ERROR.error = null; 1449 | } else if (then$$ === undefined) { 1450 | fulfill(promise, maybeThenable); 1451 | } else if (isFunction(then$$)) { 1452 | handleForeignThenable(promise, maybeThenable, then$$); 1453 | } else { 1454 | fulfill(promise, maybeThenable); 1455 | } 1456 | } 1457 | } 1458 | 1459 | function _resolve(promise, value) { 1460 | if (promise === value) { 1461 | _reject(promise, selfFulfillment()); 1462 | } else if (objectOrFunction(value)) { 1463 | handleMaybeThenable(promise, value, getThen(value)); 1464 | } else { 1465 | fulfill(promise, value); 1466 | } 1467 | } 1468 | 1469 | function publishRejection(promise) { 1470 | if (promise._onerror) { 1471 | promise._onerror(promise._result); 1472 | } 1473 | 1474 | publish(promise); 1475 | } 1476 | 1477 | function fulfill(promise, value) { 1478 | if (promise._state !== PENDING) { 1479 | return; 1480 | } 1481 | 1482 | promise._result = value; 1483 | promise._state = FULFILLED; 1484 | 1485 | if (promise._subscribers.length !== 0) { 1486 | asap(publish, promise); 1487 | } 1488 | } 1489 | 1490 | function _reject(promise, reason) { 1491 | if (promise._state !== PENDING) { 1492 | return; 1493 | } 1494 | promise._state = REJECTED; 1495 | promise._result = reason; 1496 | 1497 | asap(publishRejection, promise); 1498 | } 1499 | 1500 | function subscribe(parent, child, onFulfillment, onRejection) { 1501 | var _subscribers = parent._subscribers; 1502 | var length = _subscribers.length; 1503 | 1504 | parent._onerror = null; 1505 | 1506 | _subscribers[length] = child; 1507 | _subscribers[length + FULFILLED] = onFulfillment; 1508 | _subscribers[length + REJECTED] = onRejection; 1509 | 1510 | if (length === 0 && parent._state) { 1511 | asap(publish, parent); 1512 | } 1513 | } 1514 | 1515 | function publish(promise) { 1516 | var subscribers = promise._subscribers; 1517 | var settled = promise._state; 1518 | 1519 | if (subscribers.length === 0) { 1520 | return; 1521 | } 1522 | 1523 | var child = undefined, 1524 | callback = undefined, 1525 | detail = promise._result; 1526 | 1527 | for (var i = 0; i < subscribers.length; i += 3) { 1528 | child = subscribers[i]; 1529 | callback = subscribers[i + settled]; 1530 | 1531 | if (child) { 1532 | invokeCallback(settled, child, callback, detail); 1533 | } else { 1534 | callback(detail); 1535 | } 1536 | } 1537 | 1538 | promise._subscribers.length = 0; 1539 | } 1540 | 1541 | function ErrorObject() { 1542 | this.error = null; 1543 | } 1544 | 1545 | var TRY_CATCH_ERROR = new ErrorObject(); 1546 | 1547 | function tryCatch(callback, detail) { 1548 | try { 1549 | return callback(detail); 1550 | } catch (e) { 1551 | TRY_CATCH_ERROR.error = e; 1552 | return TRY_CATCH_ERROR; 1553 | } 1554 | } 1555 | 1556 | function invokeCallback(settled, promise, callback, detail) { 1557 | var hasCallback = isFunction(callback), 1558 | value = undefined, 1559 | error = undefined, 1560 | succeeded = undefined, 1561 | failed = undefined; 1562 | 1563 | if (hasCallback) { 1564 | value = tryCatch(callback, detail); 1565 | 1566 | if (value === TRY_CATCH_ERROR) { 1567 | failed = true; 1568 | error = value.error; 1569 | value.error = null; 1570 | } else { 1571 | succeeded = true; 1572 | } 1573 | 1574 | if (promise === value) { 1575 | _reject(promise, cannotReturnOwn()); 1576 | return; 1577 | } 1578 | } else { 1579 | value = detail; 1580 | succeeded = true; 1581 | } 1582 | 1583 | if (promise._state !== PENDING) { 1584 | // noop 1585 | } else if (hasCallback && succeeded) { 1586 | _resolve(promise, value); 1587 | } else if (failed) { 1588 | _reject(promise, error); 1589 | } else if (settled === FULFILLED) { 1590 | fulfill(promise, value); 1591 | } else if (settled === REJECTED) { 1592 | _reject(promise, value); 1593 | } 1594 | } 1595 | 1596 | function initializePromise(promise, resolver) { 1597 | try { 1598 | resolver(function resolvePromise(value) { 1599 | _resolve(promise, value); 1600 | }, function rejectPromise(reason) { 1601 | _reject(promise, reason); 1602 | }); 1603 | } catch (e) { 1604 | _reject(promise, e); 1605 | } 1606 | } 1607 | 1608 | var id = 0; 1609 | function nextId() { 1610 | return id++; 1611 | } 1612 | 1613 | function makePromise(promise) { 1614 | promise[PROMISE_ID] = id++; 1615 | promise._state = undefined; 1616 | promise._result = undefined; 1617 | promise._subscribers = []; 1618 | } 1619 | 1620 | function Enumerator(Constructor, input) { 1621 | this._instanceConstructor = Constructor; 1622 | this.promise = new Constructor(noop); 1623 | 1624 | if (!this.promise[PROMISE_ID]) { 1625 | makePromise(this.promise); 1626 | } 1627 | 1628 | if (isArray(input)) { 1629 | this._input = input; 1630 | this.length = input.length; 1631 | this._remaining = input.length; 1632 | 1633 | this._result = new Array(this.length); 1634 | 1635 | if (this.length === 0) { 1636 | fulfill(this.promise, this._result); 1637 | } else { 1638 | this.length = this.length || 0; 1639 | this._enumerate(); 1640 | if (this._remaining === 0) { 1641 | fulfill(this.promise, this._result); 1642 | } 1643 | } 1644 | } else { 1645 | _reject(this.promise, validationError()); 1646 | } 1647 | } 1648 | 1649 | function validationError() { 1650 | return new Error('Array Methods must be provided an Array'); 1651 | }; 1652 | 1653 | Enumerator.prototype._enumerate = function () { 1654 | var length = this.length; 1655 | var _input = this._input; 1656 | 1657 | for (var i = 0; this._state === PENDING && i < length; i++) { 1658 | this._eachEntry(_input[i], i); 1659 | } 1660 | }; 1661 | 1662 | Enumerator.prototype._eachEntry = function (entry, i) { 1663 | var c = this._instanceConstructor; 1664 | var resolve$$ = c.resolve; 1665 | 1666 | if (resolve$$ === resolve) { 1667 | var _then = getThen(entry); 1668 | 1669 | if (_then === then && entry._state !== PENDING) { 1670 | this._settledAt(entry._state, i, entry._result); 1671 | } else if (typeof _then !== 'function') { 1672 | this._remaining--; 1673 | this._result[i] = entry; 1674 | } else if (c === Promise) { 1675 | var promise = new c(noop); 1676 | handleMaybeThenable(promise, entry, _then); 1677 | this._willSettleAt(promise, i); 1678 | } else { 1679 | this._willSettleAt(new c(function (resolve$$) { 1680 | return resolve$$(entry); 1681 | }), i); 1682 | } 1683 | } else { 1684 | this._willSettleAt(resolve$$(entry), i); 1685 | } 1686 | }; 1687 | 1688 | Enumerator.prototype._settledAt = function (state, i, value) { 1689 | var promise = this.promise; 1690 | 1691 | if (promise._state === PENDING) { 1692 | this._remaining--; 1693 | 1694 | if (state === REJECTED) { 1695 | _reject(promise, value); 1696 | } else { 1697 | this._result[i] = value; 1698 | } 1699 | } 1700 | 1701 | if (this._remaining === 0) { 1702 | fulfill(promise, this._result); 1703 | } 1704 | }; 1705 | 1706 | Enumerator.prototype._willSettleAt = function (promise, i) { 1707 | var enumerator = this; 1708 | 1709 | subscribe(promise, undefined, function (value) { 1710 | return enumerator._settledAt(FULFILLED, i, value); 1711 | }, function (reason) { 1712 | return enumerator._settledAt(REJECTED, i, reason); 1713 | }); 1714 | }; 1715 | 1716 | /** 1717 | `Promise.all` accepts an array of promises, and returns a new promise which 1718 | is fulfilled with an array of fulfillment values for the passed promises, or 1719 | rejected with the reason of the first passed promise to be rejected. It casts all 1720 | elements of the passed iterable to promises as it runs this algorithm. 1721 | 1722 | Example: 1723 | 1724 | ```javascript 1725 | let promise1 = resolve(1); 1726 | let promise2 = resolve(2); 1727 | let promise3 = resolve(3); 1728 | let promises = [ promise1, promise2, promise3 ]; 1729 | 1730 | Promise.all(promises).then(function(array){ 1731 | // The array here would be [ 1, 2, 3 ]; 1732 | }); 1733 | ``` 1734 | 1735 | If any of the `promises` given to `all` are rejected, the first promise 1736 | that is rejected will be given as an argument to the returned promises's 1737 | rejection handler. For example: 1738 | 1739 | Example: 1740 | 1741 | ```javascript 1742 | let promise1 = resolve(1); 1743 | let promise2 = reject(new Error("2")); 1744 | let promise3 = reject(new Error("3")); 1745 | let promises = [ promise1, promise2, promise3 ]; 1746 | 1747 | Promise.all(promises).then(function(array){ 1748 | // Code here never runs because there are rejected promises! 1749 | }, function(error) { 1750 | // error.message === "2" 1751 | }); 1752 | ``` 1753 | 1754 | @method all 1755 | @static 1756 | @param {Array} entries array of promises 1757 | @param {String} label optional string for labeling the promise. 1758 | Useful for tooling. 1759 | @return {Promise} promise that is fulfilled when all `promises` have been 1760 | fulfilled, or rejected if any of them become rejected. 1761 | @static 1762 | */ 1763 | function all(entries) { 1764 | return new Enumerator(this, entries).promise; 1765 | } 1766 | 1767 | /** 1768 | `Promise.race` returns a new promise which is settled in the same way as the 1769 | first passed promise to settle. 1770 | 1771 | Example: 1772 | 1773 | ```javascript 1774 | let promise1 = new Promise(function(resolve, reject){ 1775 | setTimeout(function(){ 1776 | resolve('promise 1'); 1777 | }, 200); 1778 | }); 1779 | 1780 | let promise2 = new Promise(function(resolve, reject){ 1781 | setTimeout(function(){ 1782 | resolve('promise 2'); 1783 | }, 100); 1784 | }); 1785 | 1786 | Promise.race([promise1, promise2]).then(function(result){ 1787 | // result === 'promise 2' because it was resolved before promise1 1788 | // was resolved. 1789 | }); 1790 | ``` 1791 | 1792 | `Promise.race` is deterministic in that only the state of the first 1793 | settled promise matters. For example, even if other promises given to the 1794 | `promises` array argument are resolved, but the first settled promise has 1795 | become rejected before the other promises became fulfilled, the returned 1796 | promise will become rejected: 1797 | 1798 | ```javascript 1799 | let promise1 = new Promise(function(resolve, reject){ 1800 | setTimeout(function(){ 1801 | resolve('promise 1'); 1802 | }, 200); 1803 | }); 1804 | 1805 | let promise2 = new Promise(function(resolve, reject){ 1806 | setTimeout(function(){ 1807 | reject(new Error('promise 2')); 1808 | }, 100); 1809 | }); 1810 | 1811 | Promise.race([promise1, promise2]).then(function(result){ 1812 | // Code here never runs 1813 | }, function(reason){ 1814 | // reason.message === 'promise 2' because promise 2 became rejected before 1815 | // promise 1 became fulfilled 1816 | }); 1817 | ``` 1818 | 1819 | An example real-world use case is implementing timeouts: 1820 | 1821 | ```javascript 1822 | Promise.race([ajax('foo.json'), timeout(5000)]) 1823 | ``` 1824 | 1825 | @method race 1826 | @static 1827 | @param {Array} promises array of promises to observe 1828 | Useful for tooling. 1829 | @return {Promise} a promise which settles in the same way as the first passed 1830 | promise to settle. 1831 | */ 1832 | function race(entries) { 1833 | /*jshint validthis:true */ 1834 | var Constructor = this; 1835 | 1836 | if (!isArray(entries)) { 1837 | return new Constructor(function (_, reject) { 1838 | return reject(new TypeError('You must pass an array to race.')); 1839 | }); 1840 | } else { 1841 | return new Constructor(function (resolve, reject) { 1842 | var length = entries.length; 1843 | for (var i = 0; i < length; i++) { 1844 | Constructor.resolve(entries[i]).then(resolve, reject); 1845 | } 1846 | }); 1847 | } 1848 | } 1849 | 1850 | /** 1851 | `Promise.reject` returns a promise rejected with the passed `reason`. 1852 | It is shorthand for the following: 1853 | 1854 | ```javascript 1855 | let promise = new Promise(function(resolve, reject){ 1856 | reject(new Error('WHOOPS')); 1857 | }); 1858 | 1859 | promise.then(function(value){ 1860 | // Code here doesn't run because the promise is rejected! 1861 | }, function(reason){ 1862 | // reason.message === 'WHOOPS' 1863 | }); 1864 | ``` 1865 | 1866 | Instead of writing the above, your code now simply becomes the following: 1867 | 1868 | ```javascript 1869 | let promise = Promise.reject(new Error('WHOOPS')); 1870 | 1871 | promise.then(function(value){ 1872 | // Code here doesn't run because the promise is rejected! 1873 | }, function(reason){ 1874 | // reason.message === 'WHOOPS' 1875 | }); 1876 | ``` 1877 | 1878 | @method reject 1879 | @static 1880 | @param {Any} reason value that the returned promise will be rejected with. 1881 | Useful for tooling. 1882 | @return {Promise} a promise rejected with the given `reason`. 1883 | */ 1884 | function reject(reason) { 1885 | /*jshint validthis:true */ 1886 | var Constructor = this; 1887 | var promise = new Constructor(noop); 1888 | _reject(promise, reason); 1889 | return promise; 1890 | } 1891 | 1892 | function needsResolver() { 1893 | throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); 1894 | } 1895 | 1896 | function needsNew() { 1897 | throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); 1898 | } 1899 | 1900 | /** 1901 | Promise objects represent the eventual result of an asynchronous operation. The 1902 | primary way of interacting with a promise is through its `then` method, which 1903 | registers callbacks to receive either a promise's eventual value or the reason 1904 | why the promise cannot be fulfilled. 1905 | 1906 | Terminology 1907 | ----------- 1908 | 1909 | - `promise` is an object or function with a `then` method whose behavior conforms to this specification. 1910 | - `thenable` is an object or function that defines a `then` method. 1911 | - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). 1912 | - `exception` is a value that is thrown using the throw statement. 1913 | - `reason` is a value that indicates why a promise was rejected. 1914 | - `settled` the final resting state of a promise, fulfilled or rejected. 1915 | 1916 | A promise can be in one of three states: pending, fulfilled, or rejected. 1917 | 1918 | Promises that are fulfilled have a fulfillment value and are in the fulfilled 1919 | state. Promises that are rejected have a rejection reason and are in the 1920 | rejected state. A fulfillment value is never a thenable. 1921 | 1922 | Promises can also be said to *resolve* a value. If this value is also a 1923 | promise, then the original promise's settled state will match the value's 1924 | settled state. So a promise that *resolves* a promise that rejects will 1925 | itself reject, and a promise that *resolves* a promise that fulfills will 1926 | itself fulfill. 1927 | 1928 | 1929 | Basic Usage: 1930 | ------------ 1931 | 1932 | ```js 1933 | let promise = new Promise(function(resolve, reject) { 1934 | // on success 1935 | resolve(value); 1936 | 1937 | // on failure 1938 | reject(reason); 1939 | }); 1940 | 1941 | promise.then(function(value) { 1942 | // on fulfillment 1943 | }, function(reason) { 1944 | // on rejection 1945 | }); 1946 | ``` 1947 | 1948 | Advanced Usage: 1949 | --------------- 1950 | 1951 | Promises shine when abstracting away asynchronous interactions such as 1952 | `XMLHttpRequest`s. 1953 | 1954 | ```js 1955 | function getJSON(url) { 1956 | return new Promise(function(resolve, reject){ 1957 | let xhr = new XMLHttpRequest(); 1958 | 1959 | xhr.open('GET', url); 1960 | xhr.onreadystatechange = handler; 1961 | xhr.responseType = 'json'; 1962 | xhr.setRequestHeader('Accept', 'application/json'); 1963 | xhr.send(); 1964 | 1965 | function handler() { 1966 | if (this.readyState === this.DONE) { 1967 | if (this.status === 200) { 1968 | resolve(this.response); 1969 | } else { 1970 | reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); 1971 | } 1972 | } 1973 | }; 1974 | }); 1975 | } 1976 | 1977 | getJSON('/posts.json').then(function(json) { 1978 | // on fulfillment 1979 | }, function(reason) { 1980 | // on rejection 1981 | }); 1982 | ``` 1983 | 1984 | Unlike callbacks, promises are great composable primitives. 1985 | 1986 | ```js 1987 | Promise.all([ 1988 | getJSON('/posts'), 1989 | getJSON('/comments') 1990 | ]).then(function(values){ 1991 | values[0] // => postsJSON 1992 | values[1] // => commentsJSON 1993 | 1994 | return values; 1995 | }); 1996 | ``` 1997 | 1998 | @class Promise 1999 | @param {function} resolver 2000 | Useful for tooling. 2001 | @constructor 2002 | */ 2003 | function Promise(resolver) { 2004 | this[PROMISE_ID] = nextId(); 2005 | this._result = this._state = undefined; 2006 | this._subscribers = []; 2007 | 2008 | if (noop !== resolver) { 2009 | typeof resolver !== 'function' && needsResolver(); 2010 | this instanceof Promise ? initializePromise(this, resolver) : needsNew(); 2011 | } 2012 | } 2013 | 2014 | Promise.all = all; 2015 | Promise.race = race; 2016 | Promise.resolve = resolve; 2017 | Promise.reject = reject; 2018 | Promise._setScheduler = setScheduler; 2019 | Promise._setAsap = setAsap; 2020 | Promise._asap = asap; 2021 | 2022 | Promise.prototype = { 2023 | constructor: Promise, 2024 | 2025 | /** 2026 | The primary way of interacting with a promise is through its `then` method, 2027 | which registers callbacks to receive either a promise's eventual value or the 2028 | reason why the promise cannot be fulfilled. 2029 | 2030 | ```js 2031 | findUser().then(function(user){ 2032 | // user is available 2033 | }, function(reason){ 2034 | // user is unavailable, and you are given the reason why 2035 | }); 2036 | ``` 2037 | 2038 | Chaining 2039 | -------- 2040 | 2041 | The return value of `then` is itself a promise. This second, 'downstream' 2042 | promise is resolved with the return value of the first promise's fulfillment 2043 | or rejection handler, or rejected if the handler throws an exception. 2044 | 2045 | ```js 2046 | findUser().then(function (user) { 2047 | return user.name; 2048 | }, function (reason) { 2049 | return 'default name'; 2050 | }).then(function (userName) { 2051 | // If `findUser` fulfilled, `userName` will be the user's name, otherwise it 2052 | // will be `'default name'` 2053 | }); 2054 | 2055 | findUser().then(function (user) { 2056 | throw new Error('Found user, but still unhappy'); 2057 | }, function (reason) { 2058 | throw new Error('`findUser` rejected and we're unhappy'); 2059 | }).then(function (value) { 2060 | // never reached 2061 | }, function (reason) { 2062 | // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. 2063 | // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. 2064 | }); 2065 | ``` 2066 | If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. 2067 | 2068 | ```js 2069 | findUser().then(function (user) { 2070 | throw new PedagogicalException('Upstream error'); 2071 | }).then(function (value) { 2072 | // never reached 2073 | }).then(function (value) { 2074 | // never reached 2075 | }, function (reason) { 2076 | // The `PedgagocialException` is propagated all the way down to here 2077 | }); 2078 | ``` 2079 | 2080 | Assimilation 2081 | ------------ 2082 | 2083 | Sometimes the value you want to propagate to a downstream promise can only be 2084 | retrieved asynchronously. This can be achieved by returning a promise in the 2085 | fulfillment or rejection handler. The downstream promise will then be pending 2086 | until the returned promise is settled. This is called *assimilation*. 2087 | 2088 | ```js 2089 | findUser().then(function (user) { 2090 | return findCommentsByAuthor(user); 2091 | }).then(function (comments) { 2092 | // The user's comments are now available 2093 | }); 2094 | ``` 2095 | 2096 | If the assimliated promise rejects, then the downstream promise will also reject. 2097 | 2098 | ```js 2099 | findUser().then(function (user) { 2100 | return findCommentsByAuthor(user); 2101 | }).then(function (comments) { 2102 | // If `findCommentsByAuthor` fulfills, we'll have the value here 2103 | }, function (reason) { 2104 | // If `findCommentsByAuthor` rejects, we'll have the reason here 2105 | }); 2106 | ``` 2107 | 2108 | Simple Example 2109 | -------------- 2110 | 2111 | Synchronous Example 2112 | 2113 | ```javascript 2114 | let result; 2115 | 2116 | try { 2117 | result = findResult(); 2118 | // success 2119 | } catch(reason) { 2120 | // failure 2121 | } 2122 | ``` 2123 | 2124 | Errback Example 2125 | 2126 | ```js 2127 | findResult(function(result, err){ 2128 | if (err) { 2129 | // failure 2130 | } else { 2131 | // success 2132 | } 2133 | }); 2134 | ``` 2135 | 2136 | Promise Example; 2137 | 2138 | ```javascript 2139 | findResult().then(function(result){ 2140 | // success 2141 | }, function(reason){ 2142 | // failure 2143 | }); 2144 | ``` 2145 | 2146 | Advanced Example 2147 | -------------- 2148 | 2149 | Synchronous Example 2150 | 2151 | ```javascript 2152 | let author, books; 2153 | 2154 | try { 2155 | author = findAuthor(); 2156 | books = findBooksByAuthor(author); 2157 | // success 2158 | } catch(reason) { 2159 | // failure 2160 | } 2161 | ``` 2162 | 2163 | Errback Example 2164 | 2165 | ```js 2166 | 2167 | function foundBooks(books) { 2168 | 2169 | } 2170 | 2171 | function failure(reason) { 2172 | 2173 | } 2174 | 2175 | findAuthor(function(author, err){ 2176 | if (err) { 2177 | failure(err); 2178 | // failure 2179 | } else { 2180 | try { 2181 | findBoooksByAuthor(author, function(books, err) { 2182 | if (err) { 2183 | failure(err); 2184 | } else { 2185 | try { 2186 | foundBooks(books); 2187 | } catch(reason) { 2188 | failure(reason); 2189 | } 2190 | } 2191 | }); 2192 | } catch(error) { 2193 | failure(err); 2194 | } 2195 | // success 2196 | } 2197 | }); 2198 | ``` 2199 | 2200 | Promise Example; 2201 | 2202 | ```javascript 2203 | findAuthor(). 2204 | then(findBooksByAuthor). 2205 | then(function(books){ 2206 | // found books 2207 | }).catch(function(reason){ 2208 | // something went wrong 2209 | }); 2210 | ``` 2211 | 2212 | @method then 2213 | @param {Function} onFulfilled 2214 | @param {Function} onRejected 2215 | Useful for tooling. 2216 | @return {Promise} 2217 | */ 2218 | then: then, 2219 | 2220 | /** 2221 | `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same 2222 | as the catch block of a try/catch statement. 2223 | 2224 | ```js 2225 | function findAuthor(){ 2226 | throw new Error('couldn't find that author'); 2227 | } 2228 | 2229 | // synchronous 2230 | try { 2231 | findAuthor(); 2232 | } catch(reason) { 2233 | // something went wrong 2234 | } 2235 | 2236 | // async with promises 2237 | findAuthor().catch(function(reason){ 2238 | // something went wrong 2239 | }); 2240 | ``` 2241 | 2242 | @method catch 2243 | @param {Function} onRejection 2244 | Useful for tooling. 2245 | @return {Promise} 2246 | */ 2247 | 'catch': function _catch(onRejection) { 2248 | return this.then(null, onRejection); 2249 | } 2250 | }; 2251 | 2252 | function polyfill() { 2253 | var local = undefined; 2254 | 2255 | if (typeof global !== 'undefined') { 2256 | local = global; 2257 | } else if (typeof self !== 'undefined') { 2258 | local = self; 2259 | } else { 2260 | try { 2261 | local = Function('return this')(); 2262 | } catch (e) { 2263 | throw new Error('polyfill failed because global object is unavailable in this environment'); 2264 | } 2265 | } 2266 | 2267 | var P = local.Promise; 2268 | 2269 | if (P) { 2270 | var promiseToString = null; 2271 | try { 2272 | promiseToString = Object.prototype.toString.call(P.resolve()); 2273 | } catch (e) { 2274 | // silently ignored 2275 | } 2276 | 2277 | if (promiseToString === '[object Promise]' && !P.cast) { 2278 | return; 2279 | } 2280 | } 2281 | 2282 | local.Promise = Promise; 2283 | } 2284 | 2285 | // Strange compat.. 2286 | Promise.polyfill = polyfill; 2287 | Promise.Promise = Promise; 2288 | 2289 | return Promise; 2290 | 2291 | }))); 2292 | //# sourceMappingURL=es6-promise.map 2293 | 2294 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(8))) 2295 | 2296 | /***/ }), 2297 | /* 5 */ 2298 | /***/ (function(module, exports) { 2299 | 2300 | // removed by extract-text-webpack-plugin 2301 | 2302 | /***/ }), 2303 | /* 6 */ 2304 | /***/ (function(module, exports, __webpack_require__) { 2305 | 2306 | "use strict"; 2307 | 2308 | 2309 | Object.defineProperty(exports, "__esModule", { 2310 | value: true 2311 | }); 2312 | 2313 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global VERSION */ 2314 | 2315 | __webpack_require__(5); 2316 | 2317 | var _es6Promise = __webpack_require__(4); 2318 | 2319 | var _es6Promise2 = _interopRequireDefault(_es6Promise); 2320 | 2321 | var _utils = __webpack_require__(0); 2322 | 2323 | var Utils = _interopRequireWildcard(_utils); 2324 | 2325 | var _api = __webpack_require__(1); 2326 | 2327 | var API = _interopRequireWildcard(_api); 2328 | 2329 | var _button = __webpack_require__(2); 2330 | 2331 | var _push = __webpack_require__(3); 2332 | 2333 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 2334 | 2335 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2336 | 2337 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 2338 | 2339 | var Noty = function () { 2340 | /** 2341 | * @param {object} options 2342 | * @return {Noty} 2343 | */ 2344 | function Noty() { 2345 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 2346 | 2347 | _classCallCheck(this, Noty); 2348 | 2349 | this.options = Utils.deepExtend({}, API.Defaults, options); 2350 | this.id = this.options.id || Utils.generateID('bar'); 2351 | this.closeTimer = -1; 2352 | this.barDom = null; 2353 | this.layoutDom = null; 2354 | this.progressDom = null; 2355 | this.showing = false; 2356 | this.shown = false; 2357 | this.closed = false; 2358 | this.closing = false; 2359 | this.killable = this.options.timeout || this.options.closeWith.length > 0; 2360 | this.hasSound = this.options.sounds.sources.length > 0; 2361 | this.soundPlayed = false; 2362 | this.listeners = { 2363 | beforeShow: [], 2364 | onShow: [], 2365 | afterShow: [], 2366 | onClose: [], 2367 | afterClose: [], 2368 | onHover: [], 2369 | onTemplate: [] 2370 | }; 2371 | this.promises = { 2372 | show: null, 2373 | close: null 2374 | }; 2375 | this.on('beforeShow', this.options.callbacks.beforeShow); 2376 | this.on('onShow', this.options.callbacks.onShow); 2377 | this.on('afterShow', this.options.callbacks.afterShow); 2378 | this.on('onClose', this.options.callbacks.onClose); 2379 | this.on('afterClose', this.options.callbacks.afterClose); 2380 | this.on('onHover', this.options.callbacks.onHover); 2381 | this.on('onTemplate', this.options.callbacks.onTemplate); 2382 | 2383 | return this; 2384 | } 2385 | 2386 | /** 2387 | * @param {string} eventName 2388 | * @param {function} cb 2389 | * @return {Noty} 2390 | */ 2391 | 2392 | 2393 | _createClass(Noty, [{ 2394 | key: 'on', 2395 | value: function on(eventName) { 2396 | var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; 2397 | 2398 | if (typeof cb === 'function' && this.listeners.hasOwnProperty(eventName)) { 2399 | this.listeners[eventName].push(cb); 2400 | } 2401 | 2402 | return this; 2403 | } 2404 | 2405 | /** 2406 | * @return {Noty} 2407 | */ 2408 | 2409 | }, { 2410 | key: 'show', 2411 | value: function show() { 2412 | var _this = this; 2413 | 2414 | if (this.options.killer === true && !API.PageHidden) { 2415 | Noty.closeAll(); 2416 | } else if (typeof this.options.killer === 'string' && !API.PageHidden) { 2417 | Noty.closeAll(this.options.killer); 2418 | } else { 2419 | var queueCounts = API.getQueueCounts(this.options.queue); 2420 | 2421 | if (queueCounts.current >= queueCounts.maxVisible || API.PageHidden) { 2422 | API.addToQueue(this); 2423 | 2424 | if (API.PageHidden && this.hasSound && Utils.inArray('docHidden', this.options.sounds.conditions)) { 2425 | Utils.createAudioElements(this); 2426 | } 2427 | 2428 | if (API.PageHidden && Utils.inArray('docHidden', this.options.titleCount.conditions)) { 2429 | API.docTitle.increment(); 2430 | } 2431 | 2432 | return this; 2433 | } 2434 | } 2435 | 2436 | API.Store[this.id] = this; 2437 | 2438 | API.fire(this, 'beforeShow'); 2439 | 2440 | this.showing = true; 2441 | 2442 | if (this.closing) { 2443 | this.showing = false; 2444 | return this; 2445 | } 2446 | 2447 | API.build(this); 2448 | API.handleModal(this); 2449 | 2450 | if (this.options.force) { 2451 | this.layoutDom.insertBefore(this.barDom, this.layoutDom.firstChild); 2452 | } else { 2453 | this.layoutDom.appendChild(this.barDom); 2454 | } 2455 | 2456 | if (this.hasSound && !this.soundPlayed && Utils.inArray('docVisible', this.options.sounds.conditions)) { 2457 | Utils.createAudioElements(this); 2458 | } 2459 | 2460 | if (Utils.inArray('docVisible', this.options.titleCount.conditions)) { 2461 | API.docTitle.increment(); 2462 | } 2463 | 2464 | this.shown = true; 2465 | this.closed = false; 2466 | 2467 | // bind button events if any 2468 | if (API.hasButtons(this)) { 2469 | Object.keys(this.options.buttons).forEach(function (key) { 2470 | var btn = _this.barDom.querySelector('#' + _this.options.buttons[key].id); 2471 | Utils.addListener(btn, 'click', function (e) { 2472 | Utils.stopPropagation(e); 2473 | _this.options.buttons[key].cb(); 2474 | }); 2475 | }); 2476 | } 2477 | 2478 | this.progressDom = this.barDom.querySelector('.noty_progressbar'); 2479 | 2480 | if (Utils.inArray('click', this.options.closeWith)) { 2481 | Utils.addClass(this.barDom, 'noty_close_with_click'); 2482 | Utils.addListener(this.barDom, 'click', function (e) { 2483 | Utils.stopPropagation(e); 2484 | _this.close(); 2485 | }, false); 2486 | } 2487 | 2488 | Utils.addListener(this.barDom, 'mouseenter', function () { 2489 | API.fire(_this, 'onHover'); 2490 | }, false); 2491 | 2492 | if (this.options.timeout) Utils.addClass(this.barDom, 'noty_has_timeout'); 2493 | 2494 | if (Utils.inArray('button', this.options.closeWith)) { 2495 | Utils.addClass(this.barDom, 'noty_close_with_button'); 2496 | 2497 | var closeButton = document.createElement('div'); 2498 | Utils.addClass(closeButton, 'noty_close_button'); 2499 | closeButton.innerHTML = '×'; 2500 | this.barDom.appendChild(closeButton); 2501 | 2502 | Utils.addListener(closeButton, 'click', function (e) { 2503 | Utils.stopPropagation(e); 2504 | _this.close(); 2505 | }, false); 2506 | } 2507 | 2508 | API.fire(this, 'onShow'); 2509 | 2510 | if (this.options.animation.open === null) { 2511 | this.promises.show = new _es6Promise2.default(function (resolve) { 2512 | resolve(); 2513 | }); 2514 | } else if (typeof this.options.animation.open === 'function') { 2515 | this.promises.show = new _es6Promise2.default(this.options.animation.open.bind(this)); 2516 | } else { 2517 | Utils.addClass(this.barDom, this.options.animation.open); 2518 | this.promises.show = new _es6Promise2.default(function (resolve) { 2519 | Utils.addListener(_this.barDom, Utils.animationEndEvents, function () { 2520 | Utils.removeClass(_this.barDom, _this.options.animation.open); 2521 | resolve(); 2522 | }); 2523 | }); 2524 | } 2525 | 2526 | this.promises.show.then(function () { 2527 | var _t = _this; 2528 | setTimeout(function () { 2529 | API.openFlow(_t); 2530 | }, 100); 2531 | }); 2532 | 2533 | return this; 2534 | } 2535 | 2536 | /** 2537 | * @return {Noty} 2538 | */ 2539 | 2540 | }, { 2541 | key: 'stop', 2542 | value: function stop() { 2543 | API.dequeueClose(this); 2544 | return this; 2545 | } 2546 | 2547 | /** 2548 | * @return {Noty} 2549 | */ 2550 | 2551 | }, { 2552 | key: 'resume', 2553 | value: function resume() { 2554 | API.queueClose(this); 2555 | return this; 2556 | } 2557 | 2558 | /** 2559 | * @param {int|boolean} ms 2560 | * @return {Noty} 2561 | */ 2562 | 2563 | }, { 2564 | key: 'setTimeout', 2565 | value: function (_setTimeout) { 2566 | function setTimeout(_x) { 2567 | return _setTimeout.apply(this, arguments); 2568 | } 2569 | 2570 | setTimeout.toString = function () { 2571 | return _setTimeout.toString(); 2572 | }; 2573 | 2574 | return setTimeout; 2575 | }(function (ms) { 2576 | this.stop(); 2577 | this.options.timeout = ms; 2578 | 2579 | if (this.barDom) { 2580 | if (this.options.timeout) { 2581 | Utils.addClass(this.barDom, 'noty_has_timeout'); 2582 | } else { 2583 | Utils.removeClass(this.barDom, 'noty_has_timeout'); 2584 | } 2585 | 2586 | var _t = this; 2587 | setTimeout(function () { 2588 | // ugly fix for progressbar display bug 2589 | _t.resume(); 2590 | }, 100); 2591 | } 2592 | 2593 | return this; 2594 | }) 2595 | 2596 | /** 2597 | * @param {string} html 2598 | * @param {boolean} optionsOverride 2599 | * @return {Noty} 2600 | */ 2601 | 2602 | }, { 2603 | key: 'setText', 2604 | value: function setText(html) { 2605 | var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2606 | 2607 | if (this.barDom) { 2608 | this.barDom.querySelector('.noty_body').innerHTML = html; 2609 | } 2610 | 2611 | if (optionsOverride) this.options.text = html; 2612 | 2613 | return this; 2614 | } 2615 | 2616 | /** 2617 | * @param {string} type 2618 | * @param {boolean} optionsOverride 2619 | * @return {Noty} 2620 | */ 2621 | 2622 | }, { 2623 | key: 'setType', 2624 | value: function setType(type) { 2625 | var _this2 = this; 2626 | 2627 | var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2628 | 2629 | if (this.barDom) { 2630 | var classList = Utils.classList(this.barDom).split(' '); 2631 | 2632 | classList.forEach(function (c) { 2633 | if (c.substring(0, 11) === 'noty_type__') { 2634 | Utils.removeClass(_this2.barDom, c); 2635 | } 2636 | }); 2637 | 2638 | Utils.addClass(this.barDom, 'noty_type__' + type); 2639 | } 2640 | 2641 | if (optionsOverride) this.options.type = type; 2642 | 2643 | return this; 2644 | } 2645 | 2646 | /** 2647 | * @param {string} theme 2648 | * @param {boolean} optionsOverride 2649 | * @return {Noty} 2650 | */ 2651 | 2652 | }, { 2653 | key: 'setTheme', 2654 | value: function setTheme(theme) { 2655 | var _this3 = this; 2656 | 2657 | var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2658 | 2659 | if (this.barDom) { 2660 | var classList = Utils.classList(this.barDom).split(' '); 2661 | 2662 | classList.forEach(function (c) { 2663 | if (c.substring(0, 12) === 'noty_theme__') { 2664 | Utils.removeClass(_this3.barDom, c); 2665 | } 2666 | }); 2667 | 2668 | Utils.addClass(this.barDom, 'noty_theme__' + theme); 2669 | } 2670 | 2671 | if (optionsOverride) this.options.theme = theme; 2672 | 2673 | return this; 2674 | } 2675 | 2676 | /** 2677 | * @return {Noty} 2678 | */ 2679 | 2680 | }, { 2681 | key: 'close', 2682 | value: function close() { 2683 | var _this4 = this; 2684 | 2685 | if (this.closed) return this; 2686 | 2687 | if (!this.shown) { 2688 | // it's in the queue 2689 | API.removeFromQueue(this); 2690 | return this; 2691 | } 2692 | 2693 | API.fire(this, 'onClose'); 2694 | 2695 | this.closing = true; 2696 | 2697 | if (this.options.animation.close === null) { 2698 | this.promises.close = new _es6Promise2.default(function (resolve) { 2699 | resolve(); 2700 | }); 2701 | } else if (typeof this.options.animation.close === 'function') { 2702 | this.promises.close = new _es6Promise2.default(this.options.animation.close.bind(this)); 2703 | } else { 2704 | Utils.addClass(this.barDom, this.options.animation.close); 2705 | this.promises.close = new _es6Promise2.default(function (resolve) { 2706 | Utils.addListener(_this4.barDom, Utils.animationEndEvents, function () { 2707 | if (_this4.options.force) { 2708 | Utils.remove(_this4.barDom); 2709 | } else { 2710 | API.ghostFix(_this4); 2711 | } 2712 | resolve(); 2713 | }); 2714 | }); 2715 | } 2716 | 2717 | this.promises.close.then(function () { 2718 | API.closeFlow(_this4); 2719 | API.handleModalClose(_this4); 2720 | }); 2721 | 2722 | this.closed = true; 2723 | 2724 | return this; 2725 | } 2726 | 2727 | // API functions 2728 | 2729 | /** 2730 | * @param {boolean|string} queueName 2731 | * @return {Noty} 2732 | */ 2733 | 2734 | }], [{ 2735 | key: 'closeAll', 2736 | value: function closeAll() { 2737 | var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 2738 | 2739 | Object.keys(API.Store).forEach(function (id) { 2740 | if (queueName) { 2741 | if (API.Store[id].options.queue === queueName && API.Store[id].killable) { 2742 | API.Store[id].close(); 2743 | } 2744 | } else if (API.Store[id].killable) { 2745 | API.Store[id].close(); 2746 | } 2747 | }); 2748 | return this; 2749 | } 2750 | 2751 | /** 2752 | * @param {Object} obj 2753 | * @return {Noty} 2754 | */ 2755 | 2756 | }, { 2757 | key: 'overrideDefaults', 2758 | value: function overrideDefaults(obj) { 2759 | API.Defaults = Utils.deepExtend({}, API.Defaults, obj); 2760 | return this; 2761 | } 2762 | 2763 | /** 2764 | * @param {int} amount 2765 | * @param {string} queueName 2766 | * @return {Noty} 2767 | */ 2768 | 2769 | }, { 2770 | key: 'setMaxVisible', 2771 | value: function setMaxVisible() { 2772 | var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : API.DefaultMaxVisible; 2773 | var queueName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'global'; 2774 | 2775 | if (!API.Queues.hasOwnProperty(queueName)) { 2776 | API.Queues[queueName] = { maxVisible: amount, queue: [] }; 2777 | } 2778 | 2779 | API.Queues[queueName].maxVisible = amount; 2780 | return this; 2781 | } 2782 | 2783 | /** 2784 | * @param {string} innerHtml 2785 | * @param {String} classes 2786 | * @param {Function} cb 2787 | * @param {Object} attributes 2788 | * @return {NotyButton} 2789 | */ 2790 | 2791 | }, { 2792 | key: 'button', 2793 | value: function button(innerHtml) { 2794 | var classes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 2795 | var cb = arguments[2]; 2796 | var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; 2797 | 2798 | return new _button.NotyButton(innerHtml, classes, cb, attributes); 2799 | } 2800 | 2801 | /** 2802 | * @return {string} 2803 | */ 2804 | 2805 | }, { 2806 | key: 'version', 2807 | value: function version() { 2808 | return "3.1.0"; 2809 | } 2810 | 2811 | /** 2812 | * @param {String} workerPath 2813 | * @return {Push} 2814 | */ 2815 | 2816 | }, { 2817 | key: 'Push', 2818 | value: function Push(workerPath) { 2819 | return new _push.Push(workerPath); 2820 | } 2821 | }]); 2822 | 2823 | return Noty; 2824 | }(); 2825 | 2826 | // Document visibility change controller 2827 | 2828 | 2829 | exports.default = Noty; 2830 | Utils.visibilityChangeFlow(); 2831 | module.exports = exports['default']; 2832 | 2833 | /***/ }), 2834 | /* 7 */ 2835 | /***/ (function(module, exports) { 2836 | 2837 | // shim for using process in browser 2838 | var process = module.exports = {}; 2839 | 2840 | // cached from whatever global is present so that test runners that stub it 2841 | // don't break things. But we need to wrap it in a try catch in case it is 2842 | // wrapped in strict mode code which doesn't define any globals. It's inside a 2843 | // function because try/catches deoptimize in certain engines. 2844 | 2845 | var cachedSetTimeout; 2846 | var cachedClearTimeout; 2847 | 2848 | function defaultSetTimout() { 2849 | throw new Error('setTimeout has not been defined'); 2850 | } 2851 | function defaultClearTimeout () { 2852 | throw new Error('clearTimeout has not been defined'); 2853 | } 2854 | (function () { 2855 | try { 2856 | if (typeof setTimeout === 'function') { 2857 | cachedSetTimeout = setTimeout; 2858 | } else { 2859 | cachedSetTimeout = defaultSetTimout; 2860 | } 2861 | } catch (e) { 2862 | cachedSetTimeout = defaultSetTimout; 2863 | } 2864 | try { 2865 | if (typeof clearTimeout === 'function') { 2866 | cachedClearTimeout = clearTimeout; 2867 | } else { 2868 | cachedClearTimeout = defaultClearTimeout; 2869 | } 2870 | } catch (e) { 2871 | cachedClearTimeout = defaultClearTimeout; 2872 | } 2873 | } ()) 2874 | function runTimeout(fun) { 2875 | if (cachedSetTimeout === setTimeout) { 2876 | //normal enviroments in sane situations 2877 | return setTimeout(fun, 0); 2878 | } 2879 | // if setTimeout wasn't available but was latter defined 2880 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 2881 | cachedSetTimeout = setTimeout; 2882 | return setTimeout(fun, 0); 2883 | } 2884 | try { 2885 | // when when somebody has screwed with setTimeout but no I.E. maddness 2886 | return cachedSetTimeout(fun, 0); 2887 | } catch(e){ 2888 | try { 2889 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 2890 | return cachedSetTimeout.call(null, fun, 0); 2891 | } catch(e){ 2892 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 2893 | return cachedSetTimeout.call(this, fun, 0); 2894 | } 2895 | } 2896 | 2897 | 2898 | } 2899 | function runClearTimeout(marker) { 2900 | if (cachedClearTimeout === clearTimeout) { 2901 | //normal enviroments in sane situations 2902 | return clearTimeout(marker); 2903 | } 2904 | // if clearTimeout wasn't available but was latter defined 2905 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 2906 | cachedClearTimeout = clearTimeout; 2907 | return clearTimeout(marker); 2908 | } 2909 | try { 2910 | // when when somebody has screwed with setTimeout but no I.E. maddness 2911 | return cachedClearTimeout(marker); 2912 | } catch (e){ 2913 | try { 2914 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 2915 | return cachedClearTimeout.call(null, marker); 2916 | } catch (e){ 2917 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 2918 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout 2919 | return cachedClearTimeout.call(this, marker); 2920 | } 2921 | } 2922 | 2923 | 2924 | 2925 | } 2926 | var queue = []; 2927 | var draining = false; 2928 | var currentQueue; 2929 | var queueIndex = -1; 2930 | 2931 | function cleanUpNextTick() { 2932 | if (!draining || !currentQueue) { 2933 | return; 2934 | } 2935 | draining = false; 2936 | if (currentQueue.length) { 2937 | queue = currentQueue.concat(queue); 2938 | } else { 2939 | queueIndex = -1; 2940 | } 2941 | if (queue.length) { 2942 | drainQueue(); 2943 | } 2944 | } 2945 | 2946 | function drainQueue() { 2947 | if (draining) { 2948 | return; 2949 | } 2950 | var timeout = runTimeout(cleanUpNextTick); 2951 | draining = true; 2952 | 2953 | var len = queue.length; 2954 | while(len) { 2955 | currentQueue = queue; 2956 | queue = []; 2957 | while (++queueIndex < len) { 2958 | if (currentQueue) { 2959 | currentQueue[queueIndex].run(); 2960 | } 2961 | } 2962 | queueIndex = -1; 2963 | len = queue.length; 2964 | } 2965 | currentQueue = null; 2966 | draining = false; 2967 | runClearTimeout(timeout); 2968 | } 2969 | 2970 | process.nextTick = function (fun) { 2971 | var args = new Array(arguments.length - 1); 2972 | if (arguments.length > 1) { 2973 | for (var i = 1; i < arguments.length; i++) { 2974 | args[i - 1] = arguments[i]; 2975 | } 2976 | } 2977 | queue.push(new Item(fun, args)); 2978 | if (queue.length === 1 && !draining) { 2979 | runTimeout(drainQueue); 2980 | } 2981 | }; 2982 | 2983 | // v8 likes predictible objects 2984 | function Item(fun, array) { 2985 | this.fun = fun; 2986 | this.array = array; 2987 | } 2988 | Item.prototype.run = function () { 2989 | this.fun.apply(null, this.array); 2990 | }; 2991 | process.title = 'browser'; 2992 | process.browser = true; 2993 | process.env = {}; 2994 | process.argv = []; 2995 | process.version = ''; // empty string to avoid regexp issues 2996 | process.versions = {}; 2997 | 2998 | function noop() {} 2999 | 3000 | process.on = noop; 3001 | process.addListener = noop; 3002 | process.once = noop; 3003 | process.off = noop; 3004 | process.removeListener = noop; 3005 | process.removeAllListeners = noop; 3006 | process.emit = noop; 3007 | 3008 | process.binding = function (name) { 3009 | throw new Error('process.binding is not supported'); 3010 | }; 3011 | 3012 | process.cwd = function () { return '/' }; 3013 | process.chdir = function (dir) { 3014 | throw new Error('process.chdir is not supported'); 3015 | }; 3016 | process.umask = function() { return 0; }; 3017 | 3018 | 3019 | /***/ }), 3020 | /* 8 */ 3021 | /***/ (function(module, exports) { 3022 | 3023 | var g; 3024 | 3025 | // This works in non-strict mode 3026 | g = (function() { 3027 | return this; 3028 | })(); 3029 | 3030 | try { 3031 | // This works if eval is allowed (see CSP) 3032 | g = g || Function("return this")() || (1,eval)("this"); 3033 | } catch(e) { 3034 | // This works if the window reference is available 3035 | if(typeof window === "object") 3036 | g = window; 3037 | } 3038 | 3039 | // g can still be undefined, but nothing to do about it... 3040 | // We return undefined, instead of nothing here, so it's 3041 | // easier to handle this case. if(!global) { ...} 3042 | 3043 | module.exports = g; 3044 | 3045 | 3046 | /***/ }), 3047 | /* 9 */ 3048 | /***/ (function(module, exports) { 3049 | 3050 | /* (ignored) */ 3051 | 3052 | /***/ }) 3053 | /******/ ]); 3054 | }); 3055 | //# sourceMappingURL=noty.js.map --------------------------------------------------------------------------------