├── .esformatter ├── .eslintrc.json ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── bower.json ├── demo ├── css │ └── buttons.css ├── img │ ├── cus_suc.png │ ├── favicon.png │ ├── vs_icon.png │ └── vs_icon@2x.png ├── index.html └── js │ ├── features │ ├── common │ │ ├── directives │ │ │ ├── highlight.js │ │ │ └── main.js │ │ └── main.js │ ├── home │ │ ├── components │ │ │ ├── home.co │ │ │ ├── home.css │ │ │ └── subs │ │ │ │ ├── comparison │ │ │ │ ├── comparison.css │ │ │ │ └── index.co │ │ │ │ ├── docs │ │ │ │ ├── docs.css │ │ │ │ └── index.co │ │ │ │ ├── example │ │ │ │ ├── example.css │ │ │ │ └── index.co │ │ │ │ ├── exampletitle │ │ │ │ ├── exampletitle.css │ │ │ │ └── index.co │ │ │ │ ├── header │ │ │ │ ├── header.css │ │ │ │ └── index.co │ │ │ │ ├── importmodule │ │ │ │ ├── importmodule.css │ │ │ │ └── index.co │ │ │ │ └── install │ │ │ │ ├── index.co │ │ │ │ └── install.css │ │ └── main.js │ └── main.js │ ├── fw │ ├── ext │ │ ├── main.js │ │ └── serviceworker.js │ └── helper │ │ ├── event.js │ │ ├── ngDeclare.js │ │ └── object.js │ ├── index.js │ └── sw.js ├── dist ├── ngSweetAlert2.js └── ngSweetAlert2.min.js ├── package.json ├── postcss.config.js ├── src ├── helper │ └── object.js ├── index.js └── services │ └── swal.js ├── webpack.config.js └── webpack.config.prod.js /.esformatter: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "indent": { 4 | "value": " ", 5 | "alignComments": true, 6 | "ArrayExpression": 1, 7 | "ArrayPattern": 1, 8 | "ArrowFunctionExpression": 1, 9 | "AssignmentExpression": 1, 10 | "AssignmentExpression.BinaryExpression": 1, 11 | "AssignmentExpression.LogicalExpression": 1, 12 | "AssignmentExpression.UnaryExpression": 1, 13 | "CallExpression": 1, 14 | "CallExpression.BinaryExpression": 1, 15 | "CallExpression.LogicalExpression": 1, 16 | "CallExpression.UnaryExpression": 1, 17 | "CatchClause": 1, 18 | "ConditionalExpression": 1, 19 | "CommentInsideEmptyBlock": 1, 20 | "ClassDeclaration": 1, 21 | "ClassExpression": 1, 22 | "DoWhileStatement": 1, 23 | "ForInStatement": 1, 24 | "ForOfStatement": 1, 25 | "ForStatement": 1, 26 | "FunctionDeclaration": 1, 27 | "FunctionExpression": 1, 28 | "IfStatement": 1, 29 | "MemberExpression": 1, 30 | "MultipleVariableDeclaration": 1, 31 | "NewExpression": 1, 32 | "ObjectExpression": 1, 33 | "ObjectExpression.BinaryExpression": 1, 34 | "ObjectExpression.LogicalExpression": 1, 35 | "ObjectExpression.UnaryExpression": 1, 36 | "ObjectPattern": 1, 37 | "ParameterList": 1, 38 | "ReturnStatement": 1, 39 | "SingleVariableDeclaration": 0, 40 | "SwitchCase": 1, 41 | "SwitchStatement": 1, 42 | "TopLevelFunctionBlock": 1, 43 | "TryStatement": 1, 44 | "VariableDeclaration.BinaryExpression": 1, 45 | "VariableDeclaration.LogicalExpression": 1, 46 | "VariableDeclaration.UnaryExpression": 1, 47 | "WhileStatement": 1 48 | }, 49 | "lineBreak": { 50 | "value": "\n", 51 | 52 | "before": { 53 | "AssignmentExpression" : ">=1", 54 | "AssignmentOperator": 0, 55 | "AssignmentPattern" : 0, 56 | "ArrayPatternOpening": 0, 57 | "ArrayPatternClosing": 0, 58 | "ArrayPatternComma": 0, 59 | "ArrowFunctionExpressionArrow": 0, 60 | "ArrowFunctionExpressionOpeningBrace": 0, 61 | "ArrowFunctionExpressionClosingBrace": ">=1", 62 | "BlockStatement" : 0, 63 | "BreakKeyword": ">=1", 64 | "CallExpression" : -1, 65 | "CallExpressionOpeningParentheses" : 0, 66 | "CallExpressionClosingParentheses" : -1, 67 | "ClassDeclaration" : ">=1", 68 | "ClassExpression" : ">=1", 69 | "ClassOpeningBrace" : 0, 70 | "ClassClosingBrace" : ">=1", 71 | "ConditionalExpression" : ">=1", 72 | "CatchOpeningBrace" : 0, 73 | "CatchClosingBrace" : ">=1", 74 | "CatchKeyword": 0, 75 | "DeleteOperator" : ">=1", 76 | "DoWhileStatement" : ">=1", 77 | "DoWhileStatementOpeningBrace" : 0, 78 | "DoWhileStatementClosingBrace" : ">=1", 79 | "EndOfFile" : -1, 80 | "EmptyStatement" : -1, 81 | "FinallyKeyword" : -1, 82 | "FinallyOpeningBrace" : 0, 83 | "FinallyClosingBrace" : ">=1", 84 | "ForInStatement" : ">=1", 85 | "ForInStatementExpressionOpening" : 0, 86 | "ForInStatementExpressionClosing" : 0, 87 | "ForInStatementOpeningBrace" : 0, 88 | "ForInStatementClosingBrace" : ">=1", 89 | "ForOfStatement" : ">=1", 90 | "ForOfStatementExpressionOpening" : 0, 91 | "ForOfStatementExpressionClosing" : 0, 92 | "ForOfStatementOpeningBrace" : 0, 93 | "ForOfStatementClosingBrace" : ">=1", 94 | "ForStatement" : ">=1", 95 | "ForStatementExpressionOpening" : 0, 96 | "ForStatementExpressionClosing" : "<2", 97 | "ForStatementOpeningBrace" : 0, 98 | "ForStatementClosingBrace" : ">=1", 99 | "FunctionExpression" : -1, 100 | "FunctionExpressionOpeningBrace" : 0, 101 | "FunctionExpressionClosingBrace" : ">=1", 102 | "FunctionDeclaration" : ">=1", 103 | "FunctionDeclarationOpeningBrace" : 0, 104 | "FunctionDeclarationClosingBrace" : ">=1", 105 | "IIFEClosingParentheses" : 0, 106 | "IfStatement" : ">=1", 107 | "IfStatementOpeningBrace" : 0, 108 | "IfStatementClosingBrace" : ">=1", 109 | "ElseIfStatement" : 0, 110 | "ElseIfStatementOpeningBrace" : 0, 111 | "ElseIfStatementClosingBrace" : ">=1", 112 | "ElseStatement" : 0, 113 | "ElseStatementOpeningBrace" : 0, 114 | "ElseStatementClosingBrace" : ">=1", 115 | "LogicalExpression" : -1, 116 | "MethodDefinition": ">=1", 117 | "MemberExpressionOpening": 0, 118 | "MemberExpressionClosing": "<2", 119 | "MemberExpressionPeriod": -1, 120 | "ObjectExpressionClosingBrace" : ">=1", 121 | "ObjectPatternOpeningBrace": 0, 122 | "ObjectPatternClosingBrace": 0, 123 | "ObjectPatternComma": 0, 124 | "Property" : ">=1", 125 | "PropertyValue" : 0, 126 | "ReturnStatement" : -1, 127 | "SwitchOpeningBrace" : 0, 128 | "SwitchClosingBrace" : ">=1", 129 | "SwitchCaseColon": 0, 130 | "ThisExpression" : -1, 131 | "ThrowStatement" : ">=1", 132 | "TryKeyword": -1, 133 | "TryOpeningBrace" : 0, 134 | "TryClosingBrace" : ">=1", 135 | "VariableName" : ">=1", 136 | "VariableValue" : 0, 137 | "VariableDeclaration" : ">=1", 138 | "VariableDeclarationSemiColon" : 0, 139 | "VariableDeclarationWithoutInit" : ">=1", 140 | "WhileStatement" : ">=1", 141 | "WhileStatementOpeningBrace" : 0, 142 | "WhileStatementClosingBrace" : ">=1" 143 | }, 144 | 145 | "after": { 146 | "AssignmentExpression" : ">=1", 147 | "AssignmentOperator" : 0, 148 | "AssignmentPattern" : 0, 149 | "ArrayPatternOpening": 0, 150 | "ArrayPatternClosing": 0, 151 | "ArrayPatternComma": 0, 152 | "ArrowFunctionExpressionArrow": 0, 153 | "ArrowFunctionExpressionOpeningBrace": ">=1", 154 | "ArrowFunctionExpressionClosingBrace": -1, 155 | "BlockStatement" : 0, 156 | "BreakKeyword": -1, 157 | "CallExpression" : -1, 158 | "CallExpressionOpeningParentheses" : -1, 159 | "CallExpressionClosingParentheses" : -1, 160 | "ClassDeclaration" : ">=1", 161 | "ClassExpression" : ">=1", 162 | "ClassOpeningBrace" : ">=1", 163 | "ClassClosingBrace" : ">=1", 164 | "CatchOpeningBrace" : ">=1", 165 | "CatchClosingBrace" : ">=0", 166 | "CatchKeyword": 0, 167 | "ConditionalExpression" : ">=1", 168 | "DeleteOperator" : ">=1", 169 | "DoWhileStatement" : ">=1", 170 | "DoWhileStatementOpeningBrace" : ">=1", 171 | "DoWhileStatementClosingBrace" : 0, 172 | "EmptyStatement" : -1, 173 | "FinallyKeyword" : -1, 174 | "FinallyOpeningBrace" : ">=1", 175 | "FinallyClosingBrace" : ">=1", 176 | "ForInStatement" : ">=1", 177 | "ForInStatementExpressionOpening" : "<2", 178 | "ForInStatementExpressionClosing" : -1, 179 | "ForInStatementOpeningBrace" : ">=1", 180 | "ForInStatementClosingBrace" : ">=1", 181 | "ForOfStatement" : ">=1", 182 | "ForOfStatementExpressionOpening" : "<2", 183 | "ForOfStatementExpressionClosing" : -1, 184 | "ForOfStatementOpeningBrace" : ">=1", 185 | "ForOfStatementClosingBrace" : ">=1", 186 | "ForStatement" : ">=1", 187 | "ForStatementExpressionOpening" : "<2", 188 | "ForStatementExpressionClosing" : -1, 189 | "ForStatementOpeningBrace" : ">=1", 190 | "ForStatementClosingBrace" : ">=1", 191 | "FunctionExpression" : ">=1", 192 | "FunctionExpressionOpeningBrace" : ">=1", 193 | "FunctionExpressionClosingBrace" : -1, 194 | "FunctionDeclaration" : ">=1", 195 | "FunctionDeclarationOpeningBrace" : ">=1", 196 | "FunctionDeclarationClosingBrace" : ">=1", 197 | "IIFEOpeningParentheses" : 0, 198 | "IfStatement" : ">=1", 199 | "IfStatementOpeningBrace" : ">=1", 200 | "IfStatementClosingBrace" : ">=1", 201 | "ElseIfStatement" : ">=1", 202 | "ElseIfStatementOpeningBrace" : ">=1", 203 | "ElseIfStatementClosingBrace" : ">=1", 204 | "ElseStatement" : ">=1", 205 | "ElseStatementOpeningBrace" : ">=1", 206 | "ElseStatementClosingBrace" : ">=1", 207 | "LogicalExpression" : -1, 208 | "MethodDefinition": ">=1", 209 | "MemberExpressionOpening": "<2", 210 | "MemberExpressionClosing": "<2", 211 | "MemberExpressionPeriod": 0, 212 | "ObjectExpressionOpeningBrace" : ">=1", 213 | "ObjectPatternOpeningBrace": 0, 214 | "ObjectPatternClosingBrace": 0, 215 | "ObjectPatternComma": 0, 216 | "Property" : 0, 217 | "PropertyName" : 0, 218 | "ReturnStatement" : -1, 219 | "SwitchOpeningBrace" : ">=1", 220 | "SwitchClosingBrace" : ">=1", 221 | "SwitchCaseColon": ">=1", 222 | "ThisExpression" : 0, 223 | "ThrowStatement" : ">=1", 224 | "TryKeyword": -1, 225 | "TryOpeningBrace" : ">=1", 226 | "TryClosingBrace" : 0, 227 | "VariableValue" : -1, 228 | "VariableDeclaration" : ">=1", 229 | "VariableDeclarationSemiColon" : ">=1", 230 | "WhileStatement" : ">=1", 231 | "WhileStatementOpeningBrace" : ">=1", 232 | "WhileStatementClosingBrace" : ">=1" 233 | } 234 | }, 235 | 236 | 237 | "whiteSpace": { 238 | "value": " ", 239 | "removeTrailing" : 1, 240 | 241 | "before": { 242 | "AssignmentPattern" : 1, 243 | "ArrayExpressionOpening" : 0, 244 | "ArrayExpressionClosing" : 0, 245 | "ArrayExpressionComma" : 0, 246 | "ArrayPatternOpening": 1, 247 | "ArrayPatternClosing": 0, 248 | "ArrayPatternComma": 0, 249 | "ArrowFunctionExpressionArrow": 1, 250 | "ArrowFunctionExpressionOpeningBrace": 1, 251 | "ArrowFunctionExpressionClosingBrace": 0, 252 | "ArgumentComma" : 0, 253 | "ArgumentList" : 0, 254 | "AssignmentOperator" : 1, 255 | "BinaryExpression": 0, 256 | "BinaryExpressionOperator" : 1, 257 | "BlockComment" : 1, 258 | "CallExpression" : -1, 259 | "CallExpressionOpeningParentheses" : 0, 260 | "CallExpressionClosingParentheses" : -1, 261 | "CatchParameterList" : 0, 262 | "CatchOpeningBrace" : 1, 263 | "CatchClosingBrace" : 1, 264 | "CatchKeyword" : 1, 265 | "CommaOperator" : 0, 266 | "ClassOpeningBrace" : 1, 267 | "ClassClosingBrace" : 1, 268 | "ConditionalExpressionConsequent" : 1, 269 | "ConditionalExpressionAlternate" : 1, 270 | "DoWhileStatementOpeningBrace" : 1, 271 | "DoWhileStatementClosingBrace" : 1, 272 | "DoWhileStatementConditional" : 1, 273 | "EmptyStatement" : 0, 274 | "ExpressionClosingParentheses" : 0, 275 | "FinallyKeyword" : -1, 276 | "FinallyOpeningBrace" : 1, 277 | "FinallyClosingBrace" : 1, 278 | "ForInStatement" : 1, 279 | "ForInStatementExpressionOpening" : 1, 280 | "ForInStatementExpressionClosing" : 0, 281 | "ForInStatementOpeningBrace" : 1, 282 | "ForInStatementClosingBrace" : 1, 283 | "ForOfStatement" : 1, 284 | "ForOfStatementExpressionOpening" : 1, 285 | "ForOfStatementExpressionClosing" : 0, 286 | "ForOfStatementOpeningBrace" : 1, 287 | "ForOfStatementClosingBrace" : 1, 288 | "ForStatement" : 1, 289 | "ForStatementExpressionOpening" : 1, 290 | "ForStatementExpressionClosing" : 0, 291 | "ForStatementOpeningBrace" : 1, 292 | "ForStatementClosingBrace" : 1, 293 | "ForStatementSemicolon" : 0, 294 | "FunctionDeclarationOpeningBrace" : 1, 295 | "FunctionDeclarationClosingBrace" : 1, 296 | "FunctionExpressionOpeningBrace" : 1, 297 | "FunctionExpressionClosingBrace" : 1, 298 | "FunctionGeneratorAsterisk": 0, 299 | "FunctionName" : 1, 300 | "IIFEClosingParentheses" : 0, 301 | "IfStatementConditionalOpening" : 1, 302 | "IfStatementConditionalClosing" : 0, 303 | "IfStatementOpeningBrace" : 1, 304 | "IfStatementClosingBrace" : 1, 305 | "ModuleSpecifierClosingBrace": 0, 306 | "ElseStatementOpeningBrace" : 1, 307 | "ElseStatementClosingBrace" : 1, 308 | "ElseIfStatementOpeningBrace" : 1, 309 | "ElseIfStatementClosingBrace" : 1, 310 | "LineComment" : 1, 311 | "LogicalExpressionOperator" : 1, 312 | "MemberExpressionOpening": 0, 313 | "MemberExpressionClosing": 0, 314 | "MemberExpressionPeriod": 0, 315 | "ObjectExpressionOpeningBrace": -1, 316 | "ObjectExpressionClosingBrace": 0, 317 | "ObjectPatternOpeningBrace": 1, 318 | "ObjectPatternClosingBrace": 0, 319 | "ObjectPatternComma": 0, 320 | "Property" : 1, 321 | "PropertyName" : 1, 322 | "PropertyValue" : 1, 323 | "ParameterComma" : 0, 324 | "ParameterList" : 0, 325 | "SwitchDiscriminantOpening" : 1, 326 | "SwitchDiscriminantClosing" : 0, 327 | "SwitchCaseColon": 0, 328 | "ThrowKeyword": 1, 329 | "TryKeyword": -1, 330 | "TryOpeningBrace" : 1, 331 | "TryClosingBrace" : 1, 332 | "UnaryExpressionOperator": 0, 333 | "VariableName" : 1, 334 | "VariableValue" : 1, 335 | "VariableDeclarationSemiColon" : 0, 336 | "WhileStatementConditionalOpening" : 1, 337 | "WhileStatementConditionalClosing" : 0, 338 | "WhileStatementOpeningBrace" : 1, 339 | "WhileStatementClosingBrace" : 1 340 | }, 341 | 342 | "after": { 343 | "AssignmentPattern" : 1, 344 | "ArrayExpressionOpening" : 0, 345 | "ArrayExpressionClosing" : 0, 346 | "ArrayExpressionComma" : 1, 347 | "ArrayPatternOpening": 0, 348 | "ArrayPatternClosing": 1, 349 | "ArrayPatternComma": 1, 350 | "ArrowFunctionExpressionArrow": 1, 351 | "ArrowFunctionExpressionOpeningBrace": 0, 352 | "ArrowFunctionExpressionClosingBrace": 0, 353 | "ArgumentComma" : 1, 354 | "ArgumentList" : 0, 355 | "AssignmentOperator" : 1, 356 | "BinaryExpression": 0, 357 | "BinaryExpressionOperator" : 1, 358 | "BlockComment" : 1, 359 | "CallExpression" : -1, 360 | "CallExpressionOpeningParentheses" : -1, 361 | "CallExpressionClosingParentheses" : -1, 362 | "CatchParameterList" : 0, 363 | "CatchOpeningBrace" : 1, 364 | "CatchClosingBrace" : 1, 365 | "CatchKeyword" : 1, 366 | "ClassOpeningBrace" : 1, 367 | "ClassClosingBrace" : 1, 368 | "CommaOperator" : 1, 369 | "ConditionalExpressionConsequent" : 1, 370 | "ConditionalExpressionTest" : 1, 371 | "DoWhileStatementOpeningBrace" : 1, 372 | "DoWhileStatementClosingBrace" : 1, 373 | "DoWhileStatementBody" : 1, 374 | "EmptyStatement" : 0, 375 | "ExpressionOpeningParentheses" : 0, 376 | "FinallyKeyword" : -1, 377 | "FinallyOpeningBrace" : 1, 378 | "FinallyClosingBrace" : 1, 379 | "ForInStatement" : 1, 380 | "ForInStatementExpressionOpening" : 0, 381 | "ForInStatementExpressionClosing" : 1, 382 | "ForInStatementOpeningBrace" : 1, 383 | "ForInStatementClosingBrace" : 1, 384 | "ForOfStatement" : 1, 385 | "ForOfStatementExpressionOpening" : 0, 386 | "ForOfStatementExpressionClosing" : 1, 387 | "ForOfStatementOpeningBrace" : 1, 388 | "ForOfStatementClosingBrace" : 1, 389 | "ForStatement" : 1, 390 | "ForStatementExpressionOpening" : 0, 391 | "ForStatementExpressionClosing" : 1, 392 | "ForStatementClosingBrace" : 1, 393 | "ForStatementOpeningBrace" : 1, 394 | "ForStatementSemicolon" : 1, 395 | "FunctionReservedWord": 0, 396 | "FunctionName" : 0, 397 | "FunctionExpressionOpeningBrace" : 1, 398 | "FunctionExpressionClosingBrace" : 0, 399 | "FunctionDeclarationOpeningBrace" : 1, 400 | "FunctionDeclarationClosingBrace" : 1, 401 | "IIFEOpeningParentheses" : 0, 402 | "IfStatementConditionalOpening" : 0, 403 | "IfStatementConditionalClosing" : 1, 404 | "IfStatementOpeningBrace" : 1, 405 | "IfStatementClosingBrace" : 1, 406 | "ModuleSpecifierOpeningBrace": 0, 407 | "ElseStatementOpeningBrace" : 1, 408 | "ElseStatementClosingBrace" : 1, 409 | "ElseIfStatementOpeningBrace" : 1, 410 | "ElseIfStatementClosingBrace" : 1, 411 | "MemberExpressionClosing": 0, 412 | "MemberExpressionOpening": 0, 413 | "MemberExpressionPeriod": 0, 414 | "MethodDefinitionName": 0, 415 | "LogicalExpressionOperator" : 1, 416 | "ObjectExpressionOpeningBrace": 0, 417 | "ObjectExpressionClosingBrace": 0, 418 | "ObjectPatternOpeningBrace": 0, 419 | "ObjectPatternClosingBrace": 0, 420 | "ObjectPatternComma": 1, 421 | "Property" : 0, 422 | "PropertyName" : 0, 423 | "PropertyValue" : 0, 424 | "ParameterComma" : 1, 425 | "ParameterList" : 0, 426 | "SwitchDiscriminantOpening" : 0, 427 | "SwitchDiscriminantClosing" : 1, 428 | "ThrowKeyword": 1, 429 | "TryKeyword": -1, 430 | "TryOpeningBrace" : 1, 431 | "TryClosingBrace" : 1, 432 | "UnaryExpressionOperator": 0, 433 | "VariableName" : 1, 434 | "VariableValue" : 0, 435 | "VariableDeclarationSemiColon" : 0, 436 | "WhileStatementConditionalOpening" : 0, 437 | "WhileStatementConditionalClosing" : 1, 438 | "WhileStatementOpeningBrace" : 1, 439 | "WhileStatementClosingBrace" : 1 440 | } 441 | }, 442 | "quotes": { 443 | "type": "single", 444 | "avoidEscape": false 445 | }, 446 | "plugins": [ 447 | "esformatter-braces", 448 | "esformatter-dot-notation", 449 | "esformatter-literal-notation", 450 | "esformatter-quotes" 451 | ] 452 | } 453 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parserOptions":{ 3 | "ecmaVersion": 6, 4 | "sourceType": "module", 5 | "ecmaFeatures": { 6 | "globalReturn": true, 7 | "impliedStrict": false, 8 | "jsx": false, 9 | "experimentalObjectRestSpread": true 10 | } 11 | }, 12 | "env": { 13 | "shared-node-browser": true, 14 | "browser": true, 15 | "commonjs": true, 16 | "node": true, 17 | "es6": true, 18 | "mocha": true, 19 | "jquery": true 20 | }, 21 | "rules": { 22 | "comma-dangle": [2, "never"], 23 | "no-cond-assign": [2, "except-parens"], 24 | "no-console": 0, 25 | "no-constant-condition": 1, 26 | "no-control-regex": 2, 27 | "no-debugger": 2, 28 | "no-dupe-args": 2, 29 | "no-dupe-keys": 2, 30 | "no-duplicate-case": 2, 31 | "no-empty-character-class": 1, 32 | "no-empty": 1, 33 | "no-ex-assign": 2, 34 | "no-extra-boolean-cast": 1, 35 | "no-extra-parens": [1, "functions"], 36 | "no-extra-semi": 2, 37 | "no-func-assign": 2, 38 | "no-inner-declarations": [1, "functions"], 39 | "no-invalid-regexp": 2, 40 | "no-irregular-whitespace": 1, 41 | "no-negated-in-lhs": 2, 42 | "no-obj-calls": 2, 43 | "no-regex-spaces": 1, 44 | "no-sparse-arrays": 2, 45 | "no-unexpected-multiline": 2, 46 | "no-unreachable": 2, 47 | "use-isnan": 2, 48 | "valid-jsdoc": 0, 49 | "valid-typeof": 2, 50 | "accessor-pairs": [1, { "getWithoutSet": true, "setWithoutGet": true }], 51 | "array-callback-return": 1, 52 | "block-scoped-var": 0, 53 | "complexity": [1, 20], 54 | "consistent-return": 0, 55 | "curly": 1, 56 | "default-case": 2, 57 | "dot-location": [1, "property"], 58 | "dot-notation": [1, { "allowKeywords": true}], 59 | "eqeqeq": 2, 60 | "guard-for-in": 0, 61 | "no-alert": 2, 62 | "no-caller": 2, 63 | "no-case-declarations": 2, 64 | "no-div-regex": 1, 65 | "no-else-return": 1, 66 | "no-empty-function": 0, 67 | "no-empty-pattern": 2, 68 | "no-eq-null": 2, 69 | "no-eval": 2, 70 | "no-extend-native": 1, 71 | "no-extra-bind": 1, 72 | "no-extra-label": 1, 73 | "no-fallthrough": 2, 74 | "no-floating-decimal": 2, 75 | "no-implicit-coercion": 0, 76 | "no-implicit-globals": 0, 77 | "no-implied-eval": 2, 78 | "no-invalid-this": 0, 79 | "no-iterator": 1, 80 | "no-labels": [2, {"allowLoop": false, "allowSwitch": false}], 81 | "no-lone-blocks": 2, 82 | "no-loop-func": 2, 83 | "no-magic-numbers": 0, 84 | "no-multi-spaces": 1, 85 | "no-multi-str": 2, 86 | "no-native-reassign": 2, 87 | "no-new-func": 2, 88 | "no-new-wrappers": 2, 89 | "no-new": 1, 90 | "no-octal-escape": 1, 91 | "no-octal": 1, 92 | "no-param-reassign": [2, {"props": false}], 93 | "no-process-env": 0, 94 | "no-proto": 2, 95 | "no-redeclare": [2, { "builtinGlobals": true }], 96 | "no-return-assign": [2, "except-parens"], 97 | "no-script-url": 2, 98 | "no-self-assign": 2, 99 | "no-self-compare": 2, 100 | "no-sequences": 2, 101 | "no-throw-literal": 2, 102 | "no-unmodified-loop-condition": 1, 103 | "no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": false }], 104 | "no-unused-labels": 1, 105 | "no-useless-call": 1, 106 | "no-useless-concat": 1, 107 | "no-void": 2, 108 | "no-warning-comments": [1, { "terms": ["todo", "fix"], "location": "anywhere" }], 109 | "no-with": 2, 110 | "radix": [2, "as-needed"], 111 | "vars-on-top": 0, 112 | "wrap-iife": [2, "outside"], 113 | "yoda": [1, "never", { "onlyEquality": true }], 114 | "strict": [1, "safe"], 115 | "init-declarations": 0, 116 | "no-catch-shadow": 2, 117 | "no-delete-var": 2, 118 | "no-label-var": 2, 119 | "no-shadow-restricted-names": 2, 120 | "no-shadow": [2, {"builtinGlobals": false, "hoist": "functions"}], 121 | "no-undef-init": 1, 122 | "no-undef": [2, { "typeof": false }], 123 | "no-undefined": 0, 124 | "no-unused-vars": [1, { "vars": "all", "args": "none" }], 125 | "no-use-before-define": [1, {"functions": false, "classes": true}], 126 | "array-bracket-spacing": [1, "never"], 127 | "block-spacing": [1, "always"], 128 | "brace-style": [1, "1tbs", { "allowSingleLine": true }], 129 | "camelcase": [1, {"properties": "never"}], 130 | "comma-spacing": [2, {"before": false, "after": true}], 131 | "comma-style": [1, "last"], 132 | "computed-property-spacing": [1, "never"], 133 | "consistent-this": [1, "_this", "self", "ctx"], 134 | "eol-last": [1, "unix"], 135 | "func-names": 0, 136 | "func-style": [0, "expression", { "allowArrowFunctions": true }], 137 | "id-length": [2, {"min": 1, "max": 45, "properties": "never"}], 138 | "id-match": 0, 139 | "id-blacklist": 0, 140 | "indent": [1, 4, {"VariableDeclarator": 1, "SwitchCase": 1}], 141 | "jsx-quotes": 0, 142 | "key-spacing": [1, {"beforeColon": false, "afterColon": true}], 143 | "keyword-spacing": [1, {"before": true, "after": true}], 144 | "linebreak-style": [1, "unix"], 145 | "lines-around-comment": [1, { "beforeBlockComment": true, "afterBlockComment": false, "beforeLineComment": true, "afterLineComment": false, "allowBlockStart": true, "allowBlockEnd": true, "allowObjectStart": true, "allowArrayStart": false, "allowArrayEnd": false }], 146 | "max-depth": [1, 5], 147 | "max-len": [1, {"code": 300, "comments": 300, "tabWidth": 4, "ignoreUrls": true}], 148 | "max-nested-callbacks": [1, 5], 149 | "max-params": [1, 10], 150 | "max-statements": [1, 30, {"ignoreTopLevelFunctions": true}], 151 | "new-cap": [1, {"newIsCap": true, "capIsNew": true, "properties": false}], 152 | "new-parens": 1, 153 | "newline-after-var": 0, 154 | "newline-per-chained-call": 0, 155 | "no-array-constructor": 1, 156 | "no-bitwise": 0, 157 | "no-continue": 0, 158 | "no-inline-comments": 0, 159 | "no-lonely-if": 1, 160 | "no-mixed-spaces-and-tabs": 1, 161 | "no-multiple-empty-lines": [1, {"max": 2}], 162 | "no-negated-condition": 0, 163 | "no-nested-ternary": 1, 164 | "no-new-object": 1, 165 | "no-plusplus": 0, 166 | "no-restricted-syntax": [1, "WithStatement"], 167 | "no-whitespace-before-property": 1, 168 | "no-spaced-func": 1, 169 | "no-ternary": 0, 170 | "no-trailing-spaces": [1, { "skipBlankLines": true }], 171 | "no-underscore-dangle": 0, 172 | "no-unneeded-ternary": 1, 173 | "object-curly-spacing": [1, "never"], 174 | "one-var": 0, 175 | "one-var-declaration-per-line": 0, 176 | "operator-assignment": 0, 177 | "operator-linebreak": 0, 178 | "padded-blocks": 0, 179 | "quote-props": [1, "as-needed"], 180 | "quotes": [1, "single"], 181 | "require-jsdoc": 0, 182 | "semi-spacing": [2, { "before": false, "after": true }], 183 | "semi": [1, "always"], 184 | "sort-vars": 0, 185 | "sort-imports": 0, 186 | "space-before-blocks": [1, { "functions": "always", "keywords": "always", "classes": "always" }], 187 | "space-before-function-paren": [1, {"anonymous": "never", "named": "never"}], 188 | "space-in-parens": [1, "never"], 189 | "space-infix-ops": 1, 190 | "space-unary-ops": [1, { "words": true, "nonwords": false }], 191 | "spaced-comment": 0, 192 | "wrap-regex": 0 193 | }, 194 | "globals": { 195 | "BMap": true 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #npm 2 | node_modules/ 3 | 4 | #osx 5 | .DS_Store 6 | 7 | #build 8 | build/ -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // 将设置放入此文件中以覆盖默认值和用户设置。 2 | { 3 | "editor.formatOnSave": true, 4 | "eslint.enable": true, 5 | "html.format.enable": false 6 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tristan Edwards & Limon Monte 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular-sweetalert 2 | 3 | ================== 4 | 5 | ![][bower-url] 6 | [![NPM version][npm-image]][npm-url] 7 | ![][david-url] 8 | ![][dt-url] 9 | ![][license-url] 10 | 11 | An angular service which expose [sweetAlert2](sweetalert2-url) functions in angular way. 12 | 13 | ## What's the difference between `2.x` and `1.x`? 14 | 15 | Since [sweetAlert](https://github.com/t4t5/sweetalert) is unmaintained. I choose [sweetAlert2](https://github.com/limonte/sweetalert2) as new interface. See below: 16 | 17 | [Reason of creating this fork is inactivity of original SweetAlert plugin](http://stackoverflow.com/a/27842854/1331425) 18 | 19 | ## Requirements 20 | 21 | * [angular][angular-url] 22 | * [sweetalert2][sweetalert2-url] 23 | 24 | ## Install 25 | 26 | ### from npm 27 | 28 | ```bash 29 | npm install --save sweetalert2 angular-h-sweetalert 30 | ``` 31 | 32 | ### from bower 33 | 34 | ```bash 35 | bower install --save sweetalert2 angular-h-sweetalert 36 | ``` 37 | 38 | ## Import 39 | 40 | ### ES2015 41 | 42 | ```javascript 43 | import "sweetalert2/dist/sweetalert2.min.css"; 44 | import { ngSweetAlert2 } from "angular-h-sweetalert"; 45 | ``` 46 | 47 | ### CommonJS 48 | 49 | ```javascript 50 | require("sweetalert2/dist/sweetalert2.min.css"); 51 | const { ngSweetAlert2 } = require("angular-h-sweetalert"); 52 | ``` 53 | 54 | ### script 55 | 56 | ```html 57 | 58 | 59 | 60 | 61 | DEMO 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 72 | 73 | 74 | ``` 75 | 76 | ## Basic Usage 77 | 78 | ```javascript 79 | const demo = angular.module("demo", [ngSweetAlert2]); 80 | 81 | demo.controller("demoController", [ 82 | "$scope", 83 | "swal", 84 | function($scope, swal) { 85 | $scope.basic = function() { 86 | swal("The Internet?", "That thing is still around?", "question"); 87 | }; 88 | } 89 | ]); 90 | ``` 91 | 92 | Looking for more usage examples?, check: [examples](https://leftstick.github.io/angular-sweetalert/) 93 | 94 | ## LICENSE 95 | 96 | [MIT License](https://raw.githubusercontent.com/leftstick/angular-sweetalert/master/LICENSE) 97 | 98 | [angular-url]: https://angularjs.org/ 99 | [sweetalert2-url]: https://github.com/limonte/sweetalert2 100 | [bower-url]: https://img.shields.io/bower/v/angular-h-sweetalert.svg 101 | [npm-url]: https://npmjs.org/package/angular-h-sweetalert 102 | [npm-image]: https://badge.fury.io/js/angular-h-sweetalert.png 103 | [david-url]: https://david-dm.org/leftstick/angular-h-sweetalert.png 104 | [dt-url]: https://img.shields.io/npm/dt/angular-h-sweetalert.svg 105 | [license-url]: https://img.shields.io/npm/l/angular-h-sweetalert.svg 106 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-sweetalert", 3 | "homepage": "https://github.com/leftstick/angular-sweetalert", 4 | "description": "An angular service which expose sweetalert in angular way", 5 | "main": ["dist/ngSweetAlert2.min.js"], 6 | "keywords": ["angular", "sweetalert2"], 7 | "authors": ["Howard.Zuo"], 8 | "license": "MIT", 9 | "ignore": ["**/.*", "node_modules"] 10 | } 11 | -------------------------------------------------------------------------------- /demo/css/buttons.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | display: inline-block; 3 | padding: 6px 12px; 4 | margin-bottom: 0; 5 | font-size: 24px; 6 | font-weight: normal; 7 | line-height: 1.42857143; 8 | text-align: center; 9 | white-space: nowrap; 10 | vertical-align: middle; 11 | -ms-touch-action: manipulation; 12 | touch-action: manipulation; 13 | cursor: pointer; 14 | -webkit-user-select: none; 15 | -moz-user-select: none; 16 | -ms-user-select: none; 17 | user-select: none; 18 | background-image: none; 19 | border: 1px solid transparent; 20 | border-radius: 4px; 21 | margin: 26px 5px 0; 22 | } 23 | .btn:focus, 24 | .btn:active:focus, 25 | .btn.active:focus, 26 | .btn.focus, 27 | .btn:active.focus, 28 | .btn.active.focus { 29 | outline: thin dotted; 30 | outline: 5px auto -webkit-focus-ring-color; 31 | outline-offset: -2px; 32 | } 33 | .btn:hover, 34 | .btn:focus, 35 | .btn.focus { 36 | color: #333; 37 | text-decoration: none; 38 | } 39 | .btn:active, 40 | .btn.active { 41 | background-image: none; 42 | outline: 0; 43 | -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); 44 | box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125); 45 | } 46 | .btn.disabled, 47 | .btn[disabled], 48 | fieldset[disabled] .btn { 49 | cursor: not-allowed; 50 | filter: alpha(opacity=65); 51 | -webkit-box-shadow: none; 52 | box-shadow: none; 53 | opacity: .65; 54 | } 55 | a.btn.disabled, 56 | fieldset[disabled] a.btn { 57 | pointer-events: none; 58 | } 59 | .btn-default { 60 | color: #333; 61 | background-color: #fff; 62 | border-color: #ccc; 63 | } 64 | .btn-default:focus, 65 | .btn-default.focus { 66 | color: #333; 67 | background-color: #e6e6e6; 68 | border-color: #8c8c8c; 69 | } 70 | .btn-default:hover { 71 | color: #333; 72 | background-color: #e6e6e6; 73 | border-color: #adadad; 74 | } 75 | .btn-default:active, 76 | .btn-default.active, 77 | .open > .dropdown-toggle.btn-default { 78 | color: #333; 79 | background-color: #e6e6e6; 80 | border-color: #adadad; 81 | } 82 | .btn-default:active:hover, 83 | .btn-default.active:hover, 84 | .open > .dropdown-toggle.btn-default:hover, 85 | .btn-default:active:focus, 86 | .btn-default.active:focus, 87 | .open > .dropdown-toggle.btn-default:focus, 88 | .btn-default:active.focus, 89 | .btn-default.active.focus, 90 | .open > .dropdown-toggle.btn-default.focus { 91 | color: #333; 92 | background-color: #d4d4d4; 93 | border-color: #8c8c8c; 94 | } 95 | .btn-default:active, 96 | .btn-default.active, 97 | .open > .dropdown-toggle.btn-default { 98 | background-image: none; 99 | } 100 | .btn-default.disabled:hover, 101 | .btn-default[disabled]:hover, 102 | fieldset[disabled] .btn-default:hover, 103 | .btn-default.disabled:focus, 104 | .btn-default[disabled]:focus, 105 | fieldset[disabled] .btn-default:focus, 106 | .btn-default.disabled.focus, 107 | .btn-default[disabled].focus, 108 | fieldset[disabled] .btn-default.focus { 109 | background-color: #fff; 110 | border-color: #ccc; 111 | } 112 | .btn-default .badge { 113 | color: #fff; 114 | background-color: #333; 115 | } 116 | .btn-primary { 117 | color: #fff; 118 | background-color: #337ab7; 119 | border-color: #2e6da4; 120 | } 121 | .btn-primary:focus, 122 | .btn-primary.focus { 123 | color: #fff; 124 | background-color: #286090; 125 | border-color: #122b40; 126 | } 127 | .btn-primary:hover { 128 | color: #fff; 129 | background-color: #286090; 130 | border-color: #204d74; 131 | } 132 | .btn-primary:active, 133 | .btn-primary.active, 134 | .open > .dropdown-toggle.btn-primary { 135 | color: #fff; 136 | background-color: #286090; 137 | border-color: #204d74; 138 | } 139 | .btn-primary:active:hover, 140 | .btn-primary.active:hover, 141 | .open > .dropdown-toggle.btn-primary:hover, 142 | .btn-primary:active:focus, 143 | .btn-primary.active:focus, 144 | .open > .dropdown-toggle.btn-primary:focus, 145 | .btn-primary:active.focus, 146 | .btn-primary.active.focus, 147 | .open > .dropdown-toggle.btn-primary.focus { 148 | color: #fff; 149 | background-color: #204d74; 150 | border-color: #122b40; 151 | } 152 | .btn-primary:active, 153 | .btn-primary.active, 154 | .open > .dropdown-toggle.btn-primary { 155 | background-image: none; 156 | } 157 | .btn-primary.disabled:hover, 158 | .btn-primary[disabled]:hover, 159 | fieldset[disabled] .btn-primary:hover, 160 | .btn-primary.disabled:focus, 161 | .btn-primary[disabled]:focus, 162 | fieldset[disabled] .btn-primary:focus, 163 | .btn-primary.disabled.focus, 164 | .btn-primary[disabled].focus, 165 | fieldset[disabled] .btn-primary.focus { 166 | background-color: #337ab7; 167 | border-color: #2e6da4; 168 | } 169 | .btn-primary .badge { 170 | color: #337ab7; 171 | background-color: #fff; 172 | } 173 | .btn-success { 174 | color: #fff; 175 | background-color: #5cb85c; 176 | border-color: #4cae4c; 177 | } 178 | .btn-success:focus, 179 | .btn-success.focus { 180 | color: #fff; 181 | background-color: #449d44; 182 | border-color: #255625; 183 | } 184 | .btn-success:hover { 185 | color: #fff; 186 | background-color: #449d44; 187 | border-color: #398439; 188 | } 189 | .btn-success:active, 190 | .btn-success.active, 191 | .open > .dropdown-toggle.btn-success { 192 | color: #fff; 193 | background-color: #449d44; 194 | border-color: #398439; 195 | } 196 | .btn-success:active:hover, 197 | .btn-success.active:hover, 198 | .open > .dropdown-toggle.btn-success:hover, 199 | .btn-success:active:focus, 200 | .btn-success.active:focus, 201 | .open > .dropdown-toggle.btn-success:focus, 202 | .btn-success:active.focus, 203 | .btn-success.active.focus, 204 | .open > .dropdown-toggle.btn-success.focus { 205 | color: #fff; 206 | background-color: #398439; 207 | border-color: #255625; 208 | } 209 | .btn-success:active, 210 | .btn-success.active, 211 | .open > .dropdown-toggle.btn-success { 212 | background-image: none; 213 | } 214 | .btn-success.disabled:hover, 215 | .btn-success[disabled]:hover, 216 | fieldset[disabled] .btn-success:hover, 217 | .btn-success.disabled:focus, 218 | .btn-success[disabled]:focus, 219 | fieldset[disabled] .btn-success:focus, 220 | .btn-success.disabled.focus, 221 | .btn-success[disabled].focus, 222 | fieldset[disabled] .btn-success.focus { 223 | background-color: #5cb85c; 224 | border-color: #4cae4c; 225 | } 226 | .btn-success .badge { 227 | color: #5cb85c; 228 | background-color: #fff; 229 | } 230 | .btn-info { 231 | color: #fff; 232 | background-color: #5bc0de; 233 | border-color: #46b8da; 234 | } 235 | .btn-info:focus, 236 | .btn-info.focus { 237 | color: #fff; 238 | background-color: #31b0d5; 239 | border-color: #1b6d85; 240 | } 241 | .btn-info:hover { 242 | color: #fff; 243 | background-color: #31b0d5; 244 | border-color: #269abc; 245 | } 246 | .btn-info:active, 247 | .btn-info.active, 248 | .open > .dropdown-toggle.btn-info { 249 | color: #fff; 250 | background-color: #31b0d5; 251 | border-color: #269abc; 252 | } 253 | .btn-info:active:hover, 254 | .btn-info.active:hover, 255 | .open > .dropdown-toggle.btn-info:hover, 256 | .btn-info:active:focus, 257 | .btn-info.active:focus, 258 | .open > .dropdown-toggle.btn-info:focus, 259 | .btn-info:active.focus, 260 | .btn-info.active.focus, 261 | .open > .dropdown-toggle.btn-info.focus { 262 | color: #fff; 263 | background-color: #269abc; 264 | border-color: #1b6d85; 265 | } 266 | .btn-info:active, 267 | .btn-info.active, 268 | .open > .dropdown-toggle.btn-info { 269 | background-image: none; 270 | } 271 | .btn-info.disabled:hover, 272 | .btn-info[disabled]:hover, 273 | fieldset[disabled] .btn-info:hover, 274 | .btn-info.disabled:focus, 275 | .btn-info[disabled]:focus, 276 | fieldset[disabled] .btn-info:focus, 277 | .btn-info.disabled.focus, 278 | .btn-info[disabled].focus, 279 | fieldset[disabled] .btn-info.focus { 280 | background-color: #5bc0de; 281 | border-color: #46b8da; 282 | } 283 | .btn-info .badge { 284 | color: #5bc0de; 285 | background-color: #fff; 286 | } 287 | .btn-warning { 288 | color: #fff; 289 | background-color: #f0ad4e; 290 | border-color: #eea236; 291 | } 292 | .btn-warning:focus, 293 | .btn-warning.focus { 294 | color: #fff; 295 | background-color: #ec971f; 296 | border-color: #985f0d; 297 | } 298 | .btn-warning:hover { 299 | color: #fff; 300 | background-color: #ec971f; 301 | border-color: #d58512; 302 | } 303 | .btn-warning:active, 304 | .btn-warning.active, 305 | .open > .dropdown-toggle.btn-warning { 306 | color: #fff; 307 | background-color: #ec971f; 308 | border-color: #d58512; 309 | } 310 | .btn-warning:active:hover, 311 | .btn-warning.active:hover, 312 | .open > .dropdown-toggle.btn-warning:hover, 313 | .btn-warning:active:focus, 314 | .btn-warning.active:focus, 315 | .open > .dropdown-toggle.btn-warning:focus, 316 | .btn-warning:active.focus, 317 | .btn-warning.active.focus, 318 | .open > .dropdown-toggle.btn-warning.focus { 319 | color: #fff; 320 | background-color: #d58512; 321 | border-color: #985f0d; 322 | } 323 | .btn-warning:active, 324 | .btn-warning.active, 325 | .open > .dropdown-toggle.btn-warning { 326 | background-image: none; 327 | } 328 | .btn-warning.disabled:hover, 329 | .btn-warning[disabled]:hover, 330 | fieldset[disabled] .btn-warning:hover, 331 | .btn-warning.disabled:focus, 332 | .btn-warning[disabled]:focus, 333 | fieldset[disabled] .btn-warning:focus, 334 | .btn-warning.disabled.focus, 335 | .btn-warning[disabled].focus, 336 | fieldset[disabled] .btn-warning.focus { 337 | background-color: #f0ad4e; 338 | border-color: #eea236; 339 | } 340 | .btn-warning .badge { 341 | color: #f0ad4e; 342 | background-color: #fff; 343 | } 344 | .btn-danger { 345 | color: #fff; 346 | background-color: #d9534f; 347 | border-color: #d43f3a; 348 | } 349 | .btn-danger:focus, 350 | .btn-danger.focus { 351 | color: #fff; 352 | background-color: #c9302c; 353 | border-color: #761c19; 354 | } 355 | .btn-danger:hover { 356 | color: #fff; 357 | background-color: #c9302c; 358 | border-color: #ac2925; 359 | } 360 | .btn-danger:active, 361 | .btn-danger.active, 362 | .open > .dropdown-toggle.btn-danger { 363 | color: #fff; 364 | background-color: #c9302c; 365 | border-color: #ac2925; 366 | } 367 | .btn-danger:active:hover, 368 | .btn-danger.active:hover, 369 | .open > .dropdown-toggle.btn-danger:hover, 370 | .btn-danger:active:focus, 371 | .btn-danger.active:focus, 372 | .open > .dropdown-toggle.btn-danger:focus, 373 | .btn-danger:active.focus, 374 | .btn-danger.active.focus, 375 | .open > .dropdown-toggle.btn-danger.focus { 376 | color: #fff; 377 | background-color: #ac2925; 378 | border-color: #761c19; 379 | } 380 | .btn-danger:active, 381 | .btn-danger.active, 382 | .open > .dropdown-toggle.btn-danger { 383 | background-image: none; 384 | } 385 | .btn-danger.disabled:hover, 386 | .btn-danger[disabled]:hover, 387 | fieldset[disabled] .btn-danger:hover, 388 | .btn-danger.disabled:focus, 389 | .btn-danger[disabled]:focus, 390 | fieldset[disabled] .btn-danger:focus, 391 | .btn-danger.disabled.focus, 392 | .btn-danger[disabled].focus, 393 | fieldset[disabled] .btn-danger.focus { 394 | background-color: #d9534f; 395 | border-color: #d43f3a; 396 | } 397 | .btn-danger .badge { 398 | color: #d9534f; 399 | background-color: #fff; 400 | } 401 | -------------------------------------------------------------------------------- /demo/img/cus_suc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leftstick/angular-sweetalert/8306cb5f6203cac51e0b01e4d61cfa75ec6f9fb6/demo/img/cus_suc.png -------------------------------------------------------------------------------- /demo/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leftstick/angular-sweetalert/8306cb5f6203cac51e0b01e4d61cfa75ec6f9fb6/demo/img/favicon.png -------------------------------------------------------------------------------- /demo/img/vs_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leftstick/angular-sweetalert/8306cb5f6203cac51e0b01e4d61cfa75ec6f9fb6/demo/img/vs_icon.png -------------------------------------------------------------------------------- /demo/img/vs_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leftstick/angular-sweetalert/8306cb5f6203cac51e0b01e4d61cfa75ec6f9fb6/demo/img/vs_icon@2x.png -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | angular-h-sweetalert 7 | 8 | 9 | 14 | 15 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /demo/js/features/common/directives/highlight.js: -------------------------------------------------------------------------------- 1 | import hljs from 'highlight.js'; 2 | export default { 3 | type: 'directive', 4 | name: 'highlight', 5 | 6 | directiveFactory: function() { 7 | return { 8 | restrict: 'A', 9 | link(scope, element, attrs) { 10 | const snippets = element[0].querySelectorAll('pre code'); 11 | Array 12 | .prototype 13 | .slice 14 | .apply(snippets) 15 | .forEach(s => { 16 | hljs.highlightBlock(s); 17 | }); 18 | } 19 | }; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /demo/js/features/common/directives/main.js: -------------------------------------------------------------------------------- 1 | import highlight from './highlight'; 2 | 3 | export default [highlight]; 4 | -------------------------------------------------------------------------------- /demo/js/features/common/main.js: -------------------------------------------------------------------------------- 1 | import directives from './directives/main'; 2 | 3 | export default [...directives]; 4 | -------------------------------------------------------------------------------- /demo/js/features/home/components/home.co: -------------------------------------------------------------------------------- 1 | import './home.css'; 2 | 3 | export default { 4 | template: ` 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | `, 13 | controller: class { 14 | /* @ngInject */ 15 | constructor() {} 16 | 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /demo/js/features/home/components/home.css: -------------------------------------------------------------------------------- 1 | home { 2 | width: 100%; 3 | min-height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | background-color: #f2f4f6; 8 | padding: 10px; 9 | } 10 | 11 | pre code { 12 | border-radius: 2px; 13 | text-align: left; 14 | } 15 | 16 | button, .button { 17 | background-color: #3085d6; 18 | color: #fff; 19 | border: 0; 20 | box-shadow: none; 21 | font-size: 17px; 22 | font-weight: 500; 23 | border-radius: 3px; 24 | padding: 15px 35px; 25 | cursor: pointer; 26 | white-space: nowrap; 27 | } 28 | 29 | blockquote { 30 | margin: 0 0 10px 0; 31 | border-left: 5px solid gray; 32 | padding-left: 10px; 33 | } 34 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/comparison/comparison.css: -------------------------------------------------------------------------------- 1 | comparison { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | } 6 | 7 | comparison p { 8 | max-width: 800px; 9 | margin: 30px auto; 10 | font-size: 17px; 11 | font-weight: 100; 12 | color: #848d94; 13 | line-height: 25px; 14 | text-align: left; 15 | } 16 | 17 | comparison p strong { 18 | color: #848d94; 19 | font-weight: 800; 20 | } 21 | 22 | comparison .compare { 23 | width: 775px; 24 | position: relative; 25 | display: flex; 26 | flex-direction: row; 27 | justify-content: space-between; 28 | } 29 | 30 | comparison .compare .vs-icon { 31 | background-image: -webkit-image-set(url(../../../../../../img/vs_icon.png) 1x, url(../../../../../../img/vs_icon@2x.png) 2x); 32 | background-image: image-set(url(../../../../../../img/vs_icon.png) 1x, url(../../../../../../img/vs_icon@2x.png) 2x); 33 | background-repeat: no-repeat; 34 | width: 69px; 35 | height: 69px; 36 | position: absolute; 37 | left: 50%; 38 | margin-left: -34px; 39 | top: 50%; 40 | margin-top: -90px; 41 | z-index: 2; 42 | } 43 | 44 | comparison .showcase { 45 | text-align: center; 46 | background-color: #e2e5e8; 47 | padding: 20px; 48 | display: inline-block; 49 | width: 383px; 50 | vertical-align: top; 51 | position: relative; 52 | } 53 | 54 | comparison .showcase pre { 55 | margin: 15px 0 30px 0; 56 | } 57 | 58 | comparison .showcase h4 { 59 | font-size: 16px; 60 | color: #b3b3b3; 61 | line-height: 22px; 62 | margin: 0 auto; 63 | font-weight: 800; 64 | } 65 | 66 | comparison .showcase.sweet h4 { 67 | color: #f77; 68 | } 69 | 70 | comparison .showcase button { 71 | margin: 20px 0; 72 | } 73 | 74 | 75 | @media screen and (max-width: 780px) { 76 | comparison .compare { 77 | width: 385px; 78 | flex-direction: column; 79 | } 80 | comparison .showcase.normal { 81 | margin-bottom: 10px; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/comparison/index.co: -------------------------------------------------------------------------------- 1 | import './comparison.css'; 2 | export default { 3 | template: ` 4 |

Here’s a comparison of a standard error message. The first one uses the built-in alert-function, while the second is an angular wrapper of SweetAlert2.

5 |
6 |
7 |

Normal alert

8 | 9 |
alert('Oops! Something went wrong!')
10 |
11 | 12 |
13 | 14 |
15 |

angular-h-sweetalert

16 | 17 | 18 |
app.controller('TestCtrl', ['swal', function(swal) {
19 |     swal(
20 |         'Oops...',
21 |         'Something went wrong!',
22 |         'error'
23 |     );
24 | }]);
25 |
26 |
27 | 28 |

Pretty cool huh? SweetAlert2 automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. It's even highly customizeable, as you can see below!

29 | `, 30 | controller: class { 31 | /* @ngInject */ 32 | constructor(swal) { 33 | this.swal = swal; 34 | } 35 | 36 | nativeError() { 37 | //eslint-disable-next-line 38 | alert('Oops! Something went wrong!'); 39 | } 40 | 41 | sweetAlert() { 42 | this 43 | .swal('Oops...', 'Something went wrong!', 'error'); 44 | } 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/docs/docs.css: -------------------------------------------------------------------------------- 1 | docs { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | width: 100%; 6 | } 7 | 8 | docs h3 { 9 | width: 100%; 10 | font-size: 28px; 11 | color: #c7ccd1; 12 | text-transform: uppercase; 13 | font-family: 'Open Sans Condensed', sans-serif; 14 | margin-top: 100px; 15 | text-align: center; 16 | position: relative; 17 | } 18 | 19 | docs h3::after { 20 | content: ''; 21 | background-color: #e2e5e8; 22 | height: 4px; 23 | width: 700px; 24 | left: 50%; 25 | margin-left: -350px; 26 | position: absolute; 27 | margin-top: -50px; 28 | border-radius: 2px; 29 | } 30 | 31 | docs blockquote { 32 | width: 725px; 33 | margin-top: 20px; 34 | } 35 | 36 | @media screen and (max-width: 700px) { 37 | docs h3::after { 38 | width: auto; 39 | left: 20px; 40 | right: 20px; 41 | margin-left: 0; 42 | } 43 | } 44 | 45 | @media screen and (max-width: 725px) { 46 | docs blockquote { 47 | width: 100%; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/docs/index.co: -------------------------------------------------------------------------------- 1 | import './docs.css'; 2 | export default { 3 | template: ` 4 |

More Detailed Documentation

5 |
If you are looking for more documentation for this sweetAlert2, there is no difference between sweetAlert2 and angular-h-sweetalert in specific usage. Which means you can check official-sweetAlert2-doc for configurations & methods
6 | `, 7 | controller: class { 8 | constructor() {} 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/example/example.css: -------------------------------------------------------------------------------- 1 | example { 2 | display: flex; 3 | flex-direction: column; 4 | width: 750px; 5 | } 6 | 7 | example .example { 8 | display: flex; 9 | flex-direction: row; 10 | margin-top: 10px; 11 | } 12 | 13 | example .example .left-side { 14 | width: 300px; 15 | text-align: center; 16 | } 17 | 18 | example .example .left-side p { 19 | margin: 15px 0; 20 | font-size: 17px; 21 | font-weight: 300; 22 | color: #848d94; 23 | line-height: 25px; 24 | } 25 | 26 | example .example pre { 27 | margin-top: 55px; 28 | max-width: 420px; 29 | } 30 | 31 | example .example.jquery pre { 32 | margin-top: 95px; 33 | } 34 | 35 | example .example.twolines pre { 36 | margin-top: 80px; 37 | } 38 | 39 | @media screen and (max-width: 420px) { 40 | example .example pre { 41 | width: calc(100vw - 15px); 42 | } 43 | } 44 | 45 | @media screen and (max-width: 750px) { 46 | example { 47 | width: 100%; 48 | } 49 | 50 | example .example { 51 | display: flex; 52 | flex-direction: column; 53 | align-items: center; 54 | } 55 | 56 | example .example pre, 57 | example .example.jquery pre, 58 | example .example.twolines pre { 59 | margin-top: 25px; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/example/index.co: -------------------------------------------------------------------------------- 1 | import './example.css'; 2 | export default { 3 | template: ` 4 |
5 |
6 |

A basic message

7 | 8 |
9 |
app.controller('TestCtrl', ['swal', function(swal) {
 10 |     swal('Any fool can use a computer');
 11 | }]);
12 |
13 | 14 |
15 |
16 |

A title with a text under

17 | 18 |
19 |
app.controller('TestCtrl', ['swal', function(swal) {
 20 |     swal(
 21 |         'The Internet?',
 22 |         'That thing is still around?',
 23 |         'question'
 24 |     );
 25 | }]);
26 |
27 | 28 |
29 |
30 |

A success message

31 | 32 |
33 |
app.controller('TestCtrl', ['swal', function(swal) {
 34 |     swal(
 35 |         'Good job!',
 36 |         'You clicked the button!',
 37 |         'success'
 38 |     );
 39 | }]);
40 |
41 | 42 |
43 |
44 |

A message with auto close timer

45 | 46 |
47 |
app.controller('TestCtrl', ['swal', function(swal) {
 48 |     swal({
 49 |         title: 'Auto close alert!',
 50 |         text: 'I will close in 2 seconds.',
 51 |         timer: 2000
 52 |     })
 53 |         .then(
 54 |             function() {},
 55 |             // handling the promise rejection
 56 |             function(dismiss) {
 57 |                 if (dismiss === 'timer') {
 58 |                     console.log('I was closed by the timer')
 59 |                 }
 60 |             }
 61 |     );
 62 | }]);
63 |
64 | 65 |
66 |
67 |

Custom HTML description and buttons

68 | 69 |
70 |
app.controller('TestCtrl', ['swal', function(swal) {
 71 |     swal({
 72 |         title: '<i>HTML</i> <u>example</u>',
 73 |         type: 'info',
 74 |         html: 'You can use bold text, ' +
 75 |               '<a href="//github.com/leftstick/angular-sweetalert">links</a> ' +
 76 |               'and other HTML tags',
 77 |         showCloseButton: true,
 78 |         showCancelButton: true,
 79 |         confirmButtonText: '<i class="fa fa-thumbs-up"></i> Great!',
 80 |         cancelButtonText: '<i class="fa fa-thumbs-down"></i>'
 81 |     })
 82 |         .catch(dismiss => {
 83 |             console.log('dismissed by ' + dismiss);
 84 |         });
 85 | }]);
86 |
87 | 88 |
89 |
90 |

jQuery HTML with custom animation

91 |

(Animate.css )

92 | 93 |
94 |
app.controller('TestCtrl', ['swal', function(swal) {
 95 |     swal({
 96 |         title: 'jQuery HTML example',
 97 |         html: $('<div>')
 98 |             .addClass('some-class')
 99 |             .text('jQuery is everywhere.'),
100 |         animation: false,
101 |         customClass: 'animated tada'
102 |     });
103 | }]);
104 |
105 | 106 |
107 |
108 |

A warning message, with a function attached to the "Confirm"-button...

109 | 110 |
111 |
app.controller('TestCtrl', ['swal', function(swal) {
112 |     swal({
113 |         title: 'Are you sure?',
114 |         text: 'You would not be able to revert this!',
115 |         type: 'warning',
116 |         showCancelButton: true,
117 |         confirmButtonColor: '#3085d6',
118 |         cancelButtonColor: '#d33',
119 |         confirmButtonText: 'Yes, delete it!'
120 |     }).then(() => {
121 |         swal(
122 |             'Deleted!',
123 |             'Your file has been deleted.',
124 |             'success'
125 |         );
126 |     });
127 | }]);
128 |
129 | 130 |
131 |
132 |

... and by passing a parameter, you can execute something else for "Cancel".

133 | 134 |
135 |
app.controller('TestCtrl', ['swal', function(swal) {
136 |     swal({
137 |         title: 'Are you sure?',
138 |         text: 'You would not be able to revert this!',
139 |         type: 'warning',
140 |         showCancelButton: true,
141 |         confirmButtonColor: '#3085d6',
142 |         cancelButtonColor: '#d33',
143 |         confirmButtonText: 'Yes, delete it!',
144 |         cancelButtonText: 'No, cancel!',
145 |         confirmButtonClass: 'btn btn-success',
146 |         cancelButtonClass: 'btn btn-danger',
147 |         buttonsStyling: false
148 |     }).then(() => {
149 |         swal(
150 |             'Deleted!',
151 |             'Your file has been deleted.',
152 |             'success'
153 |         );
154 |     }, dismiss => {
155 |         // dismiss can be 'cancel', 'overlay',
156 |         // 'close', and 'timer'
157 |         if (dismiss === 'cancel') {
158 |             swal(
159 |                 'Cancelled',
160 |                 'Your imaginary file is safe :)',
161 |                 'error'
162 |             );
163 |         }
164 |     });
165 | }]);
166 |
167 | 168 |
169 |
170 |

A message with a custom image and CSS animation disabled

171 | 172 |
173 |
app.controller('TestCtrl', ['swal', function(swal) {
174 |     swal({
175 |         title: 'Sweet!',
176 |         text: 'Modal with a custom image.',
177 |         imageUrl: 'https://unsplash.it/400/200',
178 |         imageWidth: 400,
179 |         imageHeight: 200,
180 |         animation: false
181 |     });
182 | }]);
183 |
184 | 185 |
186 |
187 |

A message with custom width, padding and background

188 | 189 |
190 |
app.controller('TestCtrl', ['swal', function(swal) {
191 |     swal({
192 |         title: 'Custom width, padding, background.',
193 |         width: 600,
194 |         padding: 100,
195 |         background: '#fff url(//bit.ly/1Nqn9HU)'
196 |     });
197 | }]);
198 |
199 | 200 |
201 |
202 |

Ajax request example

203 | 204 |
205 |
app.controller('TestCtrl', ['swal', '$q', '$timeout', function(swal, $q, $timeout) {
206 |     swal({
207 |         title: 'Submit email to run ajax request',
208 |         input: 'email',
209 |         showCancelButton: true,
210 |         confirmButtonText: 'Submit',
211 |         showLoaderOnConfirm: true,
212 |         preConfirm: email => {
213 |             return $q((resolve, reject) => {
214 |                 $timeout(function() {
215 |                     if (email === 'taken@example.com') {
216 |                         return reject('This email is already taken.');
217 |                     }
218 |                     resolve();
219 |                 }, 2000);
220 |             });
221 |         },
222 |         allowOutsideClick: false
223 |     }).then(email => {
224 |         swal({
225 |             type: 'success',
226 |             title: 'Ajax request finished!',
227 |             html: 'Submitted email: ' + email
228 |         });
229 |     });
230 | }]);
231 |
232 | 233 |
234 |
235 |

Chaining modals (queue) example

236 | 237 |
238 |
app.controller('TestCtrl', ['swal', function(swal) {
239 |     swal.setDefaults({
240 |         input: 'text',
241 |         confirmButtonText: 'Next →',
242 |         showCancelButton: true,
243 |         animation: false,
244 |         progressSteps: ['1', '2', '3']
245 |     });
246 | 
247 |     const steps = [
248 |         {
249 |             title: 'Question 1',
250 |             text: 'Chaining swal2 modals is easy'
251 |         },
252 |         'Question 2',
253 |         'Question 3'
254 |     ];
255 | 
256 |     swal.queue(steps).then(result => {
257 |         swal.resetDefaults();
258 |         swal({
259 |             title: 'All done!',
260 |             html: 'Your answers: <pre>' +
261 |                 JSON.stringify(result) +
262 |                 '</pre>',
263 |             confirmButtonText: 'Lovely!',
264 |             showCancelButton: false
265 |         });
266 |     }, () => {
267 |         swal.resetDefaults();
268 |     });
269 | }]);
270 |
271 | 272 |
273 |
274 |

Dynamic queue example

275 | 276 |
277 |
app.controller('TestCtrl', ['swal', '$q', function(swal, $q) {
278 |     swal.queue([{
279 |         title: 'Your public IP',
280 |         confirmButtonText: 'Show my public IP',
281 |         text: 'Your public IP will be received ' +
282 |             'via AJAX request',
283 |         showLoaderOnConfirm: true,
284 |         preConfirm: () => {
285 |             return $q(resolve => {
286 |                 $.get('https://api.ipify.org?format=json')
287 |                     .done(data => {
288 |                         swal.insertQueueStep(data.ip);
289 |                         resolve();
290 |                     });
291 |             });
292 |         }
293 |     }]);
294 | }]);
295 |
296 | 297 | `, 298 | controller: class { 299 | /* @ngInject */ 300 | constructor(swal, $q, $timeout) { 301 | this.swal = swal; 302 | this.$q = $q; 303 | this.$timeout = $timeout; 304 | } 305 | 306 | basic() { 307 | this.swal('Any fool can use a computer'); 308 | } 309 | 310 | titleWithText() { 311 | this.swal('The Internet?', 'That thing is still around?', 'question'); 312 | } 313 | 314 | successMessage() { 315 | this.swal('Good job!', 'You clicked the button!', 'success'); 316 | } 317 | 318 | messageWithAutoClose() { 319 | this.swal({ 320 | title: 'Auto close alert!', 321 | text: 'I will close in 2 seconds.', 322 | timer: 2000 323 | }) 324 | .then( 325 | function() {}, 326 | 327 | // handling the promise rejection 328 | function(dismiss) { 329 | if (dismiss === 'timer') { 330 | console.log('I was closed by the timer') 331 | } 332 | } 333 | ); 334 | } 335 | 336 | customHtmlDescBtn() { 337 | this.swal({ 338 | title: 'HTML example', 339 | type: 'info', 340 | html: `You can use bold text, 341 | links 342 | and other HTML tags`, 343 | showCloseButton: true, 344 | showCancelButton: true, 345 | confirmButtonText: ' Great!', 346 | cancelButtonText: '' 347 | }) 348 | .catch(dismiss => { 349 | console.log(`dismissed by '${dismiss}'`); 350 | }); 351 | } 352 | 353 | jqueryAnimation() { 354 | this.swal({ 355 | title: 'jQuery HTML example', 356 | html: $('
') 357 | .addClass('some-class') 358 | .text('jQuery is everywhere.'), 359 | animation: false, 360 | customClass: 'animated tada' 361 | }); 362 | } 363 | 364 | warningWithFunctionConfirm() { 365 | this.swal({ 366 | title: 'Are you sure?', 367 | text: 'You would not be able to revert this!', 368 | type: 'warning', 369 | showCancelButton: true, 370 | confirmButtonColor: '#3085d6', 371 | cancelButtonColor: '#d33', 372 | confirmButtonText: 'Yes, delete it!' 373 | }).then(() => { 374 | this.swal( 375 | 'Deleted!', 376 | 'Your file has been deleted.', 377 | 'success' 378 | ); 379 | }); 380 | } 381 | 382 | executeForCancel() { 383 | this.swal({ 384 | title: 'Are you sure?', 385 | text: 'You would not be able to revert this!', 386 | type: 'warning', 387 | showCancelButton: true, 388 | confirmButtonColor: '#3085d6', 389 | cancelButtonColor: '#d33', 390 | confirmButtonText: 'Yes, delete it!', 391 | cancelButtonText: 'No, cancel!', 392 | confirmButtonClass: 'btn btn-success', 393 | cancelButtonClass: 'btn btn-danger', 394 | buttonsStyling: false 395 | }).then(() => { 396 | this.swal( 397 | 'Deleted!', 398 | 'Your file has been deleted.', 399 | 'success' 400 | ); 401 | }, dismiss => { 402 | // dismiss can be 'cancel', 'overlay', 403 | // 'close', and 'timer' 404 | if (dismiss === 'cancel') { 405 | this.swal( 406 | 'Cancelled', 407 | 'Your imaginary file is safe :)', 408 | 'error' 409 | ); 410 | } 411 | }); 412 | } 413 | 414 | messageWithCustomImageAndAnimation() { 415 | this.swal({ 416 | title: 'Sweet!', 417 | text: 'Modal with a custom image.', 418 | imageUrl: 'https://unsplash.it/400/200', 419 | imageWidth: 400, 420 | imageHeight: 200, 421 | animation: false 422 | }); 423 | } 424 | 425 | messageWithCustomWidthPaddingBackground() { 426 | this.swal({ 427 | title: 'Custom width, padding, background.', 428 | width: 600, 429 | padding: 100, 430 | background: '#fff url(//bit.ly/1Nqn9HU)' 431 | }); 432 | } 433 | 434 | ajaxRequest() { 435 | this.swal({ 436 | title: 'Submit email to run ajax request', 437 | input: 'email', 438 | showCancelButton: true, 439 | confirmButtonText: 'Submit', 440 | showLoaderOnConfirm: true, 441 | preConfirm: email => { 442 | return this.$q((resolve, reject) => { 443 | this.$timeout(function() { 444 | if (email === 'taken@example.com') { 445 | return reject('This email is already taken.'); 446 | } 447 | resolve(); 448 | }, 2000); 449 | }); 450 | }, 451 | allowOutsideClick: false 452 | }).then(email => { 453 | this.swal({ 454 | type: 'success', 455 | title: 'Ajax request finished!', 456 | html: 'Submitted email: ' + email 457 | }); 458 | }); 459 | } 460 | 461 | chainingModals() { 462 | this.swal.setDefaults({ 463 | input: 'text', 464 | confirmButtonText: 'Next →', 465 | showCancelButton: true, 466 | animation: false, 467 | progressSteps: ['1', '2', '3'] 468 | }); 469 | 470 | const steps = [ 471 | { 472 | title: 'Question 1', 473 | text: 'Chaining swal2 modals is easy' 474 | }, 475 | 'Question 2', 476 | 'Question 3' 477 | ]; 478 | 479 | this.swal.queue(steps).then(result => { 480 | this.swal.resetDefaults(); 481 | this.swal({ 482 | title: 'All done!', 483 | html: 'Your answers:
' +
484 |                         JSON.stringify(result) +
485 |                         '
', 486 | confirmButtonText: 'Lovely!', 487 | showCancelButton: false 488 | }); 489 | }, () => { 490 | this.swal.resetDefaults(); 491 | }); 492 | } 493 | 494 | dynamicQueue() { 495 | this.swal.queue([{ 496 | title: 'Your public IP', 497 | confirmButtonText: 'Show my public IP', 498 | text: 'Your public IP will be received ' + 499 | 'via AJAX request', 500 | showLoaderOnConfirm: true, 501 | preConfirm: () => { 502 | return this.$q(resolve => { 503 | $.get('https://api.ipify.org?format=json') 504 | .done(data => { 505 | this.swal.insertQueueStep(data.ip); 506 | resolve(); 507 | }); 508 | }); 509 | } 510 | }]); 511 | } 512 | 513 | } 514 | }; 515 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/exampletitle/exampletitle.css: -------------------------------------------------------------------------------- 1 | exampletitle { 2 | display: block; 3 | width: 100%; 4 | } 5 | 6 | exampletitle h3 { 7 | font-size: 28px; 8 | color: #c7ccd1; 9 | text-transform: uppercase; 10 | font-family: 'Open Sans Condensed', sans-serif; 11 | margin-top: 100px; 12 | text-align: center; 13 | position: relative; 14 | } 15 | 16 | exampletitle h3::after { 17 | content: ''; 18 | background-color: #e2e5e8; 19 | height: 4px; 20 | width: 700px; 21 | left: 50%; 22 | margin-left: -350px; 23 | position: absolute; 24 | margin-top: -50px; 25 | border-radius: 2px; 26 | } 27 | 28 | @media screen and (max-width: 700px) { 29 | exampletitle h3::after { 30 | width: auto; 31 | left: 20px; 32 | right: 20px; 33 | margin-left: 0; 34 | } 35 | } -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/exampletitle/index.co: -------------------------------------------------------------------------------- 1 | import './exampletitle.css'; 2 | export default { 3 | template: ` 4 |

Usage examples

5 | `, 6 | controller: class { 7 | constructor() {} 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/header/header.css: -------------------------------------------------------------------------------- 1 | header { 2 | display: block; 3 | width: 100%; 4 | text-align: center; 5 | } 6 | header h1 { 7 | font-size: 60px; 8 | color: #a8a8a8; 9 | white-space: nowrap; 10 | margin: 50px auto; 11 | } 12 | 13 | header h2 { 14 | font-size: 20px; 15 | color: #a9b2bc; 16 | line-height: 25px; 17 | text-transform: uppercase; 18 | font-weight: 300; 19 | text-align: center; 20 | display: block; 21 | margin: 10px 0; 22 | } 23 | 24 | @media screen and (max-width: 640px) { 25 | header h1 { 26 | font-size: 30px; 27 | } 28 | } -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/header/index.co: -------------------------------------------------------------------------------- 1 | import './header.css'; 2 | export default { 3 | template: ` 4 |

angular-h-sweetalert

5 | Fork me on GitHub 6 | 7 |

A beautiful and customizable replacement for JavaScript's popup boxes

8 | 9 |

Angular service for sweetalert2

10 | `, 11 | controller: class { 12 | constructor() {} 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/importmodule/importmodule.css: -------------------------------------------------------------------------------- 1 | importmodule { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | width: 100%; 6 | } 7 | 8 | importmodule h3 { 9 | width: 100%; 10 | font-size: 28px; 11 | color: #c7ccd1; 12 | text-transform: uppercase; 13 | font-family: 'Open Sans Condensed', sans-serif; 14 | margin-top: 100px; 15 | text-align: center; 16 | position: relative; 17 | } 18 | 19 | importmodule h3::after { 20 | content: ''; 21 | background-color: #e2e5e8; 22 | height: 4px; 23 | width: 700px; 24 | left: 50%; 25 | margin-left: -350px; 26 | position: absolute; 27 | margin-top: -50px; 28 | border-radius: 2px; 29 | } 30 | 31 | importmodule .import-desc { 32 | width: 725px; 33 | } 34 | 35 | importmodule .import-desc strong { 36 | margin: 10px 0; 37 | display: block; 38 | } 39 | 40 | @media screen and (max-width: 700px) { 41 | importmodule h3::after { 42 | width: auto; 43 | left: 20px; 44 | right: 20px; 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media screen and (max-width: 725px) { 50 | importmodule .import-desc { 51 | width: 100%; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/importmodule/index.co: -------------------------------------------------------------------------------- 1 | import './importmodule.css'; 2 | export default { 3 | template: ` 4 |

Import

5 |
6 | ES2015 7 |
import 'sweetalert2/dist/sweetalert2.min.css';
 8 | import {ngSweetAlert2} from 'angular-h-sweetalert';
9 | CommonJS 10 |
require('sweetalert2/dist/sweetalert2.min.css');
11 | const {ngSweetAlert2} = require('angular-h-sweetalert');
12 |
13 |
It is recommended to use webpack to bootstrap dependencies via ES2015 or CommonJS modular
14 | script 15 |
<link rel="stylesheet" href="node_modules/sweetalert2/dist/sweetalert2.min.css">
16 |             
17 | <script type="text/javascript" src="node_modules/angular/angular.min.js"></script> 18 | <script type="text/javascript" src="node_modules/sweetalert2/dist/sweetalert2.min.js"></script> 19 | <script type="text/javascript" src="node_modules/angular-h-sweetalert/dist/ngSweetAlert2.min.js"></script> 20 | <script type="text/javascript"> 21 | var ngSweetAlert2 = window.ngSweetAlert2; 22 | </script>
23 |
24 | `, 25 | controller: class { 26 | constructor() {} 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/install/index.co: -------------------------------------------------------------------------------- 1 | import './install.css'; 2 | export default { 3 | template: ` 4 |

Install

5 |
6 | npm 7 |
npm install --save sweetalert2 angular-h-sweetalert
8 | bower 9 |
bower install --save sweetalert2 angular-h-sweetalert
10 |
11 |
It is recommended to use webpack to bootstrap dependencies via ES2015 or CommonJS modular
12 | download 13 |

Alternatively, download ngSweetAlert2.js (minified version)

14 |
15 | `, 16 | controller: class { 17 | constructor() {} 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /demo/js/features/home/components/subs/install/install.css: -------------------------------------------------------------------------------- 1 | install { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | width: 100%; 6 | } 7 | 8 | install h3 { 9 | width: 100%; 10 | font-size: 28px; 11 | color: #c7ccd1; 12 | text-transform: uppercase; 13 | font-family: 'Open Sans Condensed', sans-serif; 14 | margin-top: 100px; 15 | text-align: center; 16 | position: relative; 17 | } 18 | 19 | install h3::after { 20 | content: ''; 21 | background-color: #e2e5e8; 22 | height: 4px; 23 | width: 700px; 24 | left: 50%; 25 | margin-left: -350px; 26 | position: absolute; 27 | margin-top: -50px; 28 | border-radius: 2px; 29 | } 30 | 31 | install .install-desc { 32 | width: 725px; 33 | } 34 | 35 | install .install-desc strong { 36 | margin: 10px 0; 37 | display: block; 38 | } 39 | 40 | @media screen and (max-width: 700px) { 41 | install h3::after { 42 | width: auto; 43 | left: 20px; 44 | right: 20px; 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media screen and (max-width: 725px) { 50 | install .install-desc { 51 | width: 100%; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demo/js/features/home/main.js: -------------------------------------------------------------------------------- 1 | 2 | import home from './components/home'; 3 | import header from './components/subs/header'; 4 | import comparison from './components/subs/comparison'; 5 | import install from './components/subs/install'; 6 | import importmodule from './components/subs/importmodule'; 7 | import exampletitle from './components/subs/exampletitle'; 8 | import example from './components/subs/example'; 9 | import docs from './components/subs/docs'; 10 | 11 | export default { 12 | type: 'feature', 13 | name: 'home', 14 | component: { 15 | home, 16 | header, 17 | comparison, 18 | install, 19 | importmodule, 20 | exampletitle, 21 | example, 22 | docs 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /demo/js/features/main.js: -------------------------------------------------------------------------------- 1 | import common from './common/main'; 2 | import home from './home/main'; 3 | 4 | export default [home, ...common]; 5 | -------------------------------------------------------------------------------- /demo/js/fw/ext/main.js: -------------------------------------------------------------------------------- 1 | import 'jquery'; 2 | import 'angular'; 3 | import 'highlight.js'; 4 | import 'highlight.js/styles/darcula.css'; 5 | import '../../../css/buttons.css'; 6 | import 'sweetalert2/dist/sweetalert2.min.css'; 7 | import 'font-awesome/css/font-awesome.min.css'; 8 | import 'animate.css/animate.min.css'; 9 | import {ngSweetAlert2} from '../../../../dist/ngSweetAlert2'; 10 | 11 | export default [ngSweetAlert2]; 12 | -------------------------------------------------------------------------------- /demo/js/fw/ext/serviceworker.js: -------------------------------------------------------------------------------- 1 | import runtime from 'serviceworker-webpack-plugin/lib/runtime'; 2 | 3 | export default function() { 4 | if ('serviceWorker' in navigator) { 5 | runtime.register(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /demo/js/fw/helper/event.js: -------------------------------------------------------------------------------- 1 | 2 | export function stop(e) { 3 | if (e.stopPropagation) { 4 | e.stopPropagation(); 5 | } 6 | if (e.preventDefault) { 7 | e.preventDefault(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demo/js/fw/helper/ngDeclare.js: -------------------------------------------------------------------------------- 1 | 2 | import angular from 'angular'; 3 | import {isArray, isObject, isInjectedFunction, flatten} from './object'; 4 | 5 | const FEATURE_SET = [ 6 | 'provider', 'factory', 'service', 'decorator', 7 | 'value', 'constant', 8 | 'animation', 9 | 'filter', 10 | 'controller', 11 | 'directive', 'component' 12 | ]; 13 | const FUNCTIONS_SET = ['provider', 'factory', 'service', 'decorator', 'animation', 'filter', 'controller', 'directive']; 14 | const ANYTHING_SET = ['value', 'constant', 'component']; 15 | const NO_KEY_SET = ['run', 'config']; 16 | export function declareFeatures(features) { 17 | features 18 | .map(feature => ({ 19 | feature: feature, 20 | defines: getDefinedPairs(feature, FEATURE_SET) 21 | })) 22 | .forEach(obj => { 23 | const featureModule = angular.module(obj.feature.name, []); 24 | const defines = getDefinedMethods(obj.feature, NO_KEY_SET); 25 | defines.forEach(def => { 26 | featureModule[def.method](def.value); 27 | }); 28 | obj 29 | .defines 30 | .forEach(defined => { 31 | if (FUNCTIONS_SET.includes(defined.method)) { 32 | if (isInjectedFunction(defined.value)) { 33 | return featureModule[defined.method](defined.key, defined.value); 34 | } else { 35 | console.warn(`[${defined.key}] is not a proper factory method`); 36 | } 37 | } 38 | if (ANYTHING_SET.includes(defined.method)) { 39 | return featureModule[defined.method](defined.key, defined.value); 40 | } 41 | }); 42 | }); 43 | } 44 | 45 | const VALUE_SET = ['value', 'constant']; 46 | export function declareValues(app, valueObjs) { 47 | valueObjs 48 | .map(valueObj => getDefinedPairs(valueObj, VALUE_SET)) 49 | .reduce(flatten, []) 50 | .forEach(obj => { 51 | return app[obj.method](obj.key, obj.value); 52 | }); 53 | } 54 | 55 | export function declareDirectives(app, directives) { 56 | directives 57 | .filter(dir => { 58 | const shouldUse = isInjectedFunction(dir.directiveFactory) && dir.name; 59 | if (!shouldUse) { 60 | console.warn('directive defined without property [name], or method [directiveFactory]'); 61 | } 62 | return shouldUse; 63 | }) 64 | .forEach(dir => { 65 | return app.directive(dir.name, dir.directiveFactory); 66 | }); 67 | } 68 | 69 | export function declareComponents(app, components) { 70 | components 71 | .filter(dir => { 72 | const shouldUse = isObject(dir.componentDefinitionObject) && dir.name; 73 | if (!shouldUse) { 74 | console.warn('component defined without property [name], or [componentDefinitionObject]'); 75 | } 76 | return shouldUse; 77 | }) 78 | .forEach(dir => { 79 | return app.component(dir.name, dir.componentDefinitionObject); 80 | }); 81 | } 82 | 83 | export function declareRunners(app, runners) { 84 | runners 85 | .filter(runner => { 86 | const shouldUse = isInjectedFunction(runner.run); 87 | if (!shouldUse) { 88 | console.warn('runner defined without run method'); 89 | } 90 | return shouldUse; 91 | }) 92 | .forEach(runner => { 93 | app.run(runner.run); 94 | }); 95 | } 96 | 97 | export function declareFilters(app, filters) { 98 | filters 99 | .filter(dir => { 100 | const shouldUse = isInjectedFunction(dir.filterFactory) && dir.name; 101 | if (!shouldUse) { 102 | console.warn('filter defined without property [name], or method [filterFactory]'); 103 | } 104 | return shouldUse; 105 | }) 106 | .forEach(dir => { 107 | return app.filter(dir.name, dir.filterFactory); 108 | }); 109 | } 110 | 111 | function getDefinedPairs(valueObj, SETS) { 112 | return Object 113 | .keys(valueObj) 114 | .filter(method => SETS.includes(method) && Object.keys(valueObj[method]).length) 115 | .map(method => ({ 116 | method, 117 | defines: valueObj[method] 118 | })) 119 | .map(combine => { 120 | return Object 121 | .keys(combine.defines) 122 | .map(key => ({ 123 | method: combine.method, 124 | key, 125 | value: combine.defines[key] 126 | })); 127 | }) 128 | .reduce(flatten, []); 129 | } 130 | 131 | function getDefinedMethods(valueObj, SETS) { 132 | return Object 133 | .keys(valueObj) 134 | .filter(key => SETS.includes(key) && (isArray(valueObj[key] || isInjectedFunction(valueObj[key])))) 135 | .map(method => { 136 | if (isInjectedFunction(valueObj[method])) { 137 | return [{ 138 | method: method, 139 | value: valueObj[method] 140 | }]; 141 | } 142 | return valueObj[method] 143 | .filter(v => isInjectedFunction(v)) 144 | .map(v => ({ 145 | method: method, 146 | value: v 147 | })); 148 | }) 149 | .reduce(flatten, []); 150 | } 151 | -------------------------------------------------------------------------------- /demo/js/fw/helper/object.js: -------------------------------------------------------------------------------- 1 | 2 | import {isObject, isArray, isString} from 'angular'; 3 | 4 | const clone = function(obj) { 5 | if (typeof obj !== 'object' || !obj) { 6 | return obj; 7 | } 8 | const copy = {}; 9 | for (let attr in obj) { 10 | if (obj.hasOwnProperty(attr)) { 11 | copy[attr] = obj[attr]; 12 | } 13 | } 14 | return copy; 15 | }; 16 | 17 | export {isObject, isString, isArray}; 18 | 19 | export function isBoolean(bool) { 20 | return Object.prototype.toString.call(bool) === '[object Boolean]'; 21 | } 22 | 23 | export function isNull(obj) { 24 | return obj === null || obj === undefined; 25 | } 26 | 27 | export function isFunction(bool) { 28 | return Object.prototype.toString.call(bool) === '[object Function]'; 29 | } 30 | 31 | export function omit(obj, keys) { 32 | if (!isObject(obj)) { 33 | return obj; 34 | } 35 | if (isArray(keys) && keys.length === 0) { 36 | return obj; 37 | } 38 | if (isString(keys) && !keys) { 39 | return obj; 40 | } 41 | if (!isString(keys) && !isArray(keys)) { 42 | return obj; 43 | } 44 | const o = clone(obj); 45 | keys.forEach(function(key) { 46 | delete o[key]; 47 | }); 48 | return o; 49 | } 50 | 51 | export function pluck(arr, key) { 52 | if (!isArray(arr) || arr.length === 0) { 53 | return []; 54 | } 55 | if (!key) { 56 | return arr; 57 | } 58 | return arr.map(a => a[key]); 59 | } 60 | 61 | export function isClass(func) { 62 | const msie = window.document.documentMode; 63 | // Support: IE 9-11 only 64 | // IE 9-11 do not support classes and IE9 leaks with the code below. 65 | if (msie || typeof func !== 'function') { 66 | return false; 67 | } 68 | var result = func.$$ngIsClass; 69 | if (!isBoolean(result)) { 70 | // Support: Edge 12-13 only 71 | // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6156135/ 72 | result = func.$$ngIsClass = /^(?:class\b|constructor\()/.test(stringifyFn(func)); 73 | } 74 | return result; 75 | } 76 | 77 | export function isInjectedFunction(func) { 78 | if (!isArray(func) && !isFunction(func)) { 79 | return false; 80 | } 81 | if (isFunction(func)) { 82 | return true; 83 | } 84 | if (!func.length) { 85 | return false; 86 | } 87 | if (func.length > 1) { 88 | if (!func.slice(0, func.length - 1).every(k => isString(k))) { 89 | return false; 90 | } 91 | } 92 | if (!isFunction(func[func.length - 1])) { 93 | return false; 94 | } 95 | 96 | return true; 97 | } 98 | 99 | export function flatten(previous, current) { 100 | return previous.concat(current); 101 | } 102 | 103 | function stringifyFn(fn) { 104 | // Support: Chrome 50-51 only 105 | // Creating a new string by adding `' '` at the end, to hack around some bug in Chrome v50/51 106 | // (See https://github.com/angular/angular.js/issues/14487.) 107 | return Function.prototype.toString.call(fn) + ' '; 108 | } 109 | -------------------------------------------------------------------------------- /demo/js/index.js: -------------------------------------------------------------------------------- 1 | import angular from 'angular'; 2 | import {pluck} from './fw/helper/object'; 3 | import {declareFeatures, declareDirectives, declareComponents, declareRunners, declareFilters} from './fw/helper/ngDeclare'; 4 | import Extensions from './fw/ext/main'; 5 | import worker from './fw/ext/serviceworker'; 6 | import Things from './features/main'; 7 | 8 | class DemoApp { 9 | 10 | constructor() { 11 | worker(); 12 | this.appName = 'angular-h-sweetalert'; 13 | this.features = Things.filter(t => t.type === 'feature' && t.name); 14 | } 15 | 16 | validate() { 17 | if (!this.features || this.features.length === 0) { 18 | return console.warn('No features loaded'); 19 | } 20 | 21 | const modNames = pluck(this.features, 'name').sort(); 22 | for (let i = 0; i < modNames.length - 1; i++) { 23 | if (modNames[i] === modNames[i + 1]) { 24 | throw new Error('Duplicated Module: [ ' + modNames[i] + ' ], you have to specify another name'); 25 | } 26 | } 27 | } 28 | 29 | findDependencies() { 30 | this.depends = [...Extensions, ...this.features.map(f => f.name)]; 31 | } 32 | 33 | createApp() { 34 | declareFeatures(this.features); 35 | 36 | this.app = angular.module(this.appName, this.depends); 37 | } 38 | 39 | registerServices() { 40 | declareDirectives(this.app, Things.filter(t => t.type === 'directive')); 41 | declareComponents(this.app, Things.filter(t => t.type === 'component')); 42 | declareRunners(this.app, Things.filter(t => t.type === 'runner')); 43 | declareFilters(this.app, Things.filter(t => t.type === 'filter')); 44 | } 45 | 46 | destroySplash() { 47 | document.head.removeChild(document.querySelector('#splash-spinner')); 48 | document.body.removeChild(document.querySelector('.spinner')); 49 | } 50 | 51 | launch() { 52 | angular.bootstrap(document, [this.appName]); 53 | } 54 | 55 | run() { 56 | this.validate(); 57 | this.findDependencies(); 58 | this.createApp(); 59 | this.registerServices(); 60 | this.destroySplash(); 61 | this.launch(); 62 | } 63 | } 64 | 65 | new DemoApp().run(); 66 | -------------------------------------------------------------------------------- /demo/js/sw.js: -------------------------------------------------------------------------------- 1 | const DEBUG = process.env.DEBUG; 2 | 3 | /** 4 | * When the user navigates to your site, 5 | * the browser tries to redownload the script file that defined the service worker in the background. 6 | * If there is even a byte's difference in the service worker file compared to what it currently has, 7 | * it considers it 'new'. 8 | */ 9 | const {assets} = global.serviceWorkerOption; 10 | 11 | const CACHE_NAME = (new Date()).toISOString(); 12 | 13 | const assetsToCache = assets.map(path => new URL(path, global.location).toString()); 14 | 15 | // When the service worker is first added to a computer. 16 | self.addEventListener('install', event => { 17 | // Perform install steps. 18 | if (DEBUG) { 19 | console.log('[SW] Install event'); 20 | } 21 | 22 | // Add core website files to cache during serviceworker installation. 23 | event.waitUntil( 24 | global.caches 25 | .open(CACHE_NAME) 26 | .then((cache) => { 27 | return cache.addAll(assetsToCache); 28 | }) 29 | .then(() => { 30 | if (DEBUG) { 31 | console.log('Cached assets:', assetsToCache); 32 | } 33 | }) 34 | .catch((error) => { 35 | console.error(error); 36 | throw error; 37 | }) 38 | ); 39 | }); 40 | 41 | // After the install event. 42 | self.addEventListener('activate', (event) => { 43 | if (DEBUG) { 44 | console.log('[SW] Activate event'); 45 | } 46 | 47 | // Clean the caches 48 | event.waitUntil( 49 | global.caches 50 | .keys() 51 | .then(cacheNames => { 52 | return Promise.all( 53 | cacheNames.map((cacheName) => { 54 | // Delete the caches that are not the current one. 55 | if (cacheName.indexOf(CACHE_NAME) === 0) { 56 | return null; 57 | } 58 | 59 | return global.caches.delete(cacheName); 60 | }) 61 | ); 62 | }) 63 | ); 64 | }); 65 | 66 | 67 | self.addEventListener('fetch', event => { 68 | const request = event.request; 69 | 70 | // Ignore not GET request. 71 | if (request.method !== 'GET') { 72 | if (DEBUG) { 73 | console.log(`[SW] Ignore non GET request ${request.method}`); 74 | } 75 | return; 76 | } 77 | 78 | const requestUrl = new URL(request.url); 79 | 80 | // Ignore difference origin. 81 | if (requestUrl.origin !== location.origin) { 82 | if (DEBUG) { 83 | console.log(`[SW] Ignore difference origin ${requestUrl.origin}`); 84 | } 85 | return; 86 | } 87 | 88 | const resource = global.caches.match(request) 89 | .then((response) => { 90 | if (response) { 91 | if (DEBUG) { 92 | console.log(`[SW] fetch URL ${requestUrl.href} from cache`); 93 | } 94 | 95 | return response; 96 | } 97 | 98 | // Load and cache known assets. 99 | return fetch(request) 100 | .then(responseNetwork => { 101 | if (!responseNetwork || !responseNetwork.ok) { 102 | if (DEBUG) { 103 | console.log(`[SW] URL [${ 104 | requestUrl.toString()}] wrong responseNetwork: ${ 105 | responseNetwork.status} ${responseNetwork.type}`); 106 | } 107 | 108 | return responseNetwork; 109 | } 110 | 111 | if (DEBUG) { 112 | console.log(`[SW] URL ${requestUrl.href} fetched`); 113 | } 114 | 115 | const responseCache = responseNetwork.clone(); 116 | 117 | global.caches 118 | .open(CACHE_NAME) 119 | .then((cache) => { 120 | return cache.put(request, responseCache); 121 | }) 122 | .then(() => { 123 | if (DEBUG) { 124 | console.log(`[SW] Cache asset: ${requestUrl.href}`); 125 | } 126 | }); 127 | 128 | return responseNetwork; 129 | }) 130 | .catch(() => { 131 | // User is landing on our page. 132 | if (event.request.mode === 'navigate') { 133 | return global.caches.match('./'); 134 | } 135 | 136 | return null; 137 | }); 138 | }); 139 | 140 | event.respondWith(resource); 141 | }); 142 | -------------------------------------------------------------------------------- /dist/ngSweetAlert2.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(require("angular"), require("sweetalert2")); 4 | else if(typeof define === 'function' && define.amd) 5 | define(["angular", "sweetalert2"], factory); 6 | else { 7 | var a = typeof exports === 'object' ? factory(require("angular"), require("sweetalert2")) : factory(root["angular"], root["swal"]); 8 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; 9 | } 10 | })(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) { 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 = 4); 77 | /******/ }) 78 | /************************************************************************/ 79 | /******/ ([ 80 | /* 0 */ 81 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 82 | 83 | "use strict"; 84 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_sweetalert2__ = __webpack_require__(3); 85 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_sweetalert2___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_sweetalert2__); 86 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__helper_object__ = __webpack_require__(2); 87 | /* harmony export (immutable) */ __webpack_exports__["a"] = swalService; 88 | swalService.$inject = ['$q']; 89 | 90 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 91 | 92 | 93 | 94 | 95 | function swalService($q) { 96 | 'ngInject'; 97 | 98 | var wrapper = function wrapper() { 99 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 100 | args[_key] = arguments[_key]; 101 | } 102 | 103 | var opts = args.slice(); 104 | 105 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__helper_object__["a" /* isObject */])(opts[0]) && opts[0].preConfirm) { 106 | (function () { 107 | var oldPreConfirm = opts[0].preConfirm; 108 | opts[0].preConfirm = function () { 109 | return wrapNativePromise($q, oldPreConfirm.apply(undefined, arguments), 'preConfirm should return Promise'); 110 | }; 111 | })(); 112 | } 113 | 114 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__helper_object__["a" /* isObject */])(opts[0]) && opts[0].inputOptions) { 115 | var oldInputOptions = opts[0].inputOptions; 116 | opts[0].inputOptions = wrapNativePromise($q, oldInputOptions, 'inputOptions should be Promise or literal Object'); 117 | } 118 | 119 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__helper_object__["a" /* isObject */])(opts[0]) && opts[0].inputValidator) { 120 | (function () { 121 | var oldInputValidator = opts[0].inputValidator; 122 | opts[0].inputValidator = function () { 123 | return wrapNativePromise($q, oldInputValidator.apply(undefined, arguments), 'inputValidator should return Promise'); 124 | }; 125 | })(); 126 | } 127 | 128 | var result = __WEBPACK_IMPORTED_MODULE_0_sweetalert2___default.a.apply(undefined, _toConsumableArray(opts)); 129 | if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__helper_object__["b" /* isPromise */])(result)) { 130 | return result; 131 | } 132 | 133 | return wrapNativePromise($q, result); 134 | }; 135 | 136 | Object.keys(__WEBPACK_IMPORTED_MODULE_0_sweetalert2___default.a).forEach(function (k) { 137 | wrapper[k] = __WEBPACK_IMPORTED_MODULE_0_sweetalert2___default.a[k]; 138 | }); 139 | 140 | wrapper.queue = function () { 141 | return wrapNativePromise($q, __WEBPACK_IMPORTED_MODULE_0_sweetalert2___default.a.queue.apply(__WEBPACK_IMPORTED_MODULE_0_sweetalert2___default.a, arguments), ''); 142 | }; 143 | 144 | return wrapper; 145 | } 146 | 147 | function wrapNativePromise($q, pro, msg) { 148 | return $q(function (resolve, reject) { 149 | if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__helper_object__["b" /* isPromise */])(pro)) { 150 | return reject(msg); 151 | } 152 | pro.then(resolve, reject); 153 | }); 154 | } 155 | 156 | /***/ }), 157 | /* 1 */ 158 | /***/ (function(module, exports) { 159 | 160 | module.exports = __WEBPACK_EXTERNAL_MODULE_1__; 161 | 162 | /***/ }), 163 | /* 2 */ 164 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 165 | 166 | "use strict"; 167 | /* harmony export (immutable) */ __webpack_exports__["b"] = isPromise; 168 | /* harmony export (immutable) */ __webpack_exports__["a"] = isObject; 169 | 170 | function isPromise(promise) { 171 | return !!promise && promise.then && promise.catch; 172 | } 173 | 174 | function isObject(obj) { 175 | return Object.prototype.toString.call(obj) === '[object Object]'; 176 | } 177 | 178 | /***/ }), 179 | /* 3 */ 180 | /***/ (function(module, exports) { 181 | 182 | module.exports = __WEBPACK_EXTERNAL_MODULE_3__; 183 | 184 | /***/ }), 185 | /* 4 */ 186 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 187 | 188 | "use strict"; 189 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 190 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(1); 191 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__); 192 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__services_swal__ = __webpack_require__(0); 193 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ngSweetAlert2", function() { return ngSweetAlert2; }); 194 | 195 | 196 | 197 | 198 | var moduleName = 'angular-sweetalert'; 199 | __WEBPACK_IMPORTED_MODULE_0_angular___default.a.module(moduleName, []).factory('swal', __WEBPACK_IMPORTED_MODULE_1__services_swal__["a" /* swalService */]); 200 | 201 | var ngSweetAlert2 = moduleName; 202 | 203 | /***/ }) 204 | /******/ ]); 205 | }); -------------------------------------------------------------------------------- /dist/ngSweetAlert2.min.js: -------------------------------------------------------------------------------- 1 | !function(r,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("angular"),require("sweetalert2"));else if("function"==typeof define&&define.amd)define(["angular","sweetalert2"],t);else{var e="object"==typeof exports?t(require("angular"),require("sweetalert2")):t(r.angular,r.swal);for(var n in e)("object"==typeof exports?exports:r)[n]=e[n]}}(this,function(r,t){return function(r){function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};return t.m=r,t.c=e,t.i=function(r){return r},t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{configurable:!1,enumerable:!0,get:n})},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},t.p="",t(t.s=4)}([function(r,t,e){"use strict";function n(r){if(Array.isArray(r)){for(var t=0,e=Array(r.length);t { 42 | wrapper[k] = swal[k]; 43 | }); 44 | 45 | wrapper.queue = function(...args) { 46 | return wrapNativePromise($q, swal.queue(...args), ''); 47 | }; 48 | 49 | return wrapper; 50 | } 51 | 52 | function wrapNativePromise($q, pro, msg) { 53 | return $q((resolve, reject) => { 54 | if (!isPromise(pro)) { 55 | return reject(msg); 56 | } 57 | pro.then(resolve, reject); 58 | }); 59 | } 60 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const {resolve} = require('path'); 2 | const webpack = require('webpack'); 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin'); 5 | 6 | module.exports = function(env = {}) { 7 | const isDemo = !!env.isDemo; 8 | return { 9 | entry: { 10 | index: resolve(__dirname, 'demo', 'js', 'index.js'), 11 | vendor: resolve(__dirname, 'demo', 'js', 'fw', 'ext', 'main.js'), 12 | serviceworker: resolve(__dirname, 'demo', 'js', 'fw', 'ext', 'serviceworker.js') 13 | }, 14 | output: { 15 | path: resolve(__dirname, 'build'), 16 | filename: (isDemo ? '[hash].' : '') + '[name].bundle.js', 17 | chunkFilename: (isDemo ? '[hash].' : '') + '[id].bundle.js', 18 | publicPath: isDemo ? '/angular-sweetalert/' : '/' 19 | }, 20 | devServer: { 21 | contentBase: resolve(__dirname, 'build') 22 | }, 23 | devtool: isDemo ? '' : '#source-map', 24 | module: { 25 | rules: [ 26 | { 27 | test: /\.css$/, 28 | use: [ 29 | 'style-loader', 30 | 'css-loader', 31 | { 32 | loader: 'postcss-loader' 33 | } 34 | ] 35 | }, 36 | { 37 | test: /\.(js|co)$/, 38 | use: [ 39 | { 40 | loader: 'babel-loader', 41 | options: { 42 | presets: [ 43 | ['es2015', { 44 | modules: false 45 | }] 46 | ], 47 | plugins: ['transform-object-rest-spread', 'angularjs-annotate'] 48 | } 49 | }], 50 | exclude: /(node_modules)/ 51 | }, 52 | { 53 | test: /\.(eot|svg|ttf|woff|woff2|png)\w*/, 54 | use: ['file-loader'] 55 | } 56 | ] 57 | }, 58 | resolve: { 59 | modules: [ 60 | resolve(__dirname, 'node_modules'), 61 | resolve(__dirname, 'demo'), 62 | resolve(__dirname, 'demo', 'js') 63 | ], 64 | extensions: [ 65 | '.js', 66 | '.co' 67 | ] 68 | }, 69 | plugins: (isDemo ? [new webpack.optimize.UglifyJsPlugin({ 70 | compress: { 71 | warnings: false 72 | } 73 | })] : []).concat([ 74 | new webpack.DefinePlugin({ 75 | 'process.env': { 76 | DEBUG: !isDemo 77 | } 78 | }), 79 | new ServiceWorkerWebpackPlugin({ 80 | entry: resolve(__dirname, 'demo', 'js', 'sw.js'), 81 | publicPath: isDemo ? '/angular-sweetalert/' : '/' 82 | }), 83 | new webpack.ProvidePlugin({ 84 | $: 'jquery', 85 | 'window.jQuery': 'jquery' 86 | }), 87 | new webpack.optimize.CommonsChunkPlugin({ 88 | name: 'commons', 89 | chunks: ['serviceworker', 'vendor', 'index'] 90 | }), 91 | new HtmlWebpackPlugin({ 92 | filename: 'index.html', 93 | inject: 'body', 94 | template: resolve(__dirname, 'demo', 'index.html'), 95 | favicon: resolve(__dirname, 'demo', 'img', 'favicon.png'), 96 | hash: false 97 | }) 98 | ]) 99 | } 100 | }; 101 | -------------------------------------------------------------------------------- /webpack.config.prod.js: -------------------------------------------------------------------------------- 1 | const {resolve} = require('path'); 2 | const webpack = require('webpack'); 3 | const UnminifiedWebpackPlugin = require('unminified-webpack-plugin'); 4 | 5 | module.exports = { 6 | entry: { 7 | index: resolve(__dirname, 'src', 'index.js') 8 | }, 9 | output: { 10 | path: resolve(__dirname, 'dist'), 11 | filename: 'ngSweetAlert2.min.js', 12 | libraryTarget: 'umd' 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.js$/, 18 | use: [ 19 | { 20 | loader: 'babel-loader', 21 | options: { 22 | presets: [ 23 | ['es2015', { 24 | modules: false 25 | }] 26 | ], 27 | plugins: ['transform-object-rest-spread', 'angularjs-annotate'] 28 | } 29 | }], 30 | exclude: /(node_modules)/ 31 | } 32 | ] 33 | }, 34 | externals: { 35 | angular: 'angular', 36 | sweetalert2: { 37 | commonjs2: 'sweetalert2', 38 | commonjs: 'sweetalert2', 39 | amd: 'sweetalert2', 40 | root: 'swal' 41 | } 42 | }, 43 | resolve: { 44 | extensions: [ 45 | '.js' 46 | ] 47 | }, 48 | plugins: [ 49 | new webpack.optimize.UglifyJsPlugin({ 50 | compress: { 51 | warnings: false 52 | } 53 | }), 54 | new UnminifiedWebpackPlugin() 55 | ] 56 | }; 57 | --------------------------------------------------------------------------------