├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SweetAlert.js ├── SweetAlert.min.js ├── bower.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # generic (system) files/extensions we don't want 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | .idea/* 10 | *.DS_Store 11 | lib-cov 12 | pids 13 | logs 14 | results 15 | 16 | node_modules 17 | 18 | bower_components -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.1 2 | 3 | ## Features 4 | 5 | - expose showInputError and close methods from swal object 6 | 7 | 8 | ## 1.1.0 9 | 10 | ## Features 11 | 12 | - update angular ~1.3.0 13 | 14 | Improvements: 15 | 16 | - Replace use of $timeout with $evalAsync 17 | 18 | 19 | # 1.0.4 20 | 21 | 22 | # 1.0.3 23 | 24 | ## Features 25 | 26 | - update sweetalert 0.2.0 27 | 28 | ## Bug Fixes 29 | 30 | ## Breaking Changes 31 | 32 | 33 | # 1.0.2 34 | 35 | ## Features 36 | 37 | ## Bug Fixes 38 | 39 | - remove console.log 40 | 41 | ## Breaking Changes 42 | 43 | 44 | # 1.0.1 45 | 46 | ## Features 47 | 48 | ## Bug Fixes 49 | 50 | - call SweetAlert.swal inside another SweetAlert.swal( 51 | 52 | ## Breaking Changes 53 | 54 | 55 | # 1.0.0 56 | 57 | ## Features 58 | 59 | - SweetAlert.swal( "title" ) 60 | - SweetAlert.swal( "title", "message" ) 61 | - SweetAlert.swal( "title", "message", "type" ) 62 | - SweetAlert.swal( {options} ) 63 | - SweetAlert.success( "title", "message" ) 64 | - SweetAlert.warning( "title", "message" ) 65 | - SweetAlert.error( "title", "message" ) 66 | - SweetAlert.info( "title", "message" ) 67 | 68 | ## Bug Fixes 69 | 70 | ## Breaking Changes 71 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Pedro Sampaio 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 | # AngularJS wrapper for SweetAlert 2 | 3 | AngularJS wrapper for [SweetAlert](https://sweetalert.js.org/). Sweet Alert is a beautiful replacement for Javascript's "Alert". 4 | 5 | ## Demo 6 | [http://oitozero.github.io/ngSweetAlert/](http://oitozero.github.io/ngSweetAlert/) 7 | 8 | ## Dependencies 9 | - required: 10 | [AngularJS](https://github.com/angular/angular) 11 | [sweetalert](https://github.com/t4t5/sweetalert) 12 | 13 | ## Install 14 | 1. download the files 15 | 1. Bower 16 | 1. add `"angular-sweetalert": "latest"` to your `bower.json` file then run `bower install` OR run `bower install angular-sweetalert` 17 | 2. include the files in your app 18 | 1. `SweetAlert.min.js` 19 | 2. `sweet-alert.js` OR `sweet-alert.min.js` 20 | 3. `sweet-alert.css` 21 | 3. include the module in angular (i.e. in `app.js`) - `oitozero.ngSweetAlert` 22 | 23 | 24 | ## Documentation 25 | 26 | - [http://oitozero.github.io/ngSweetAlert/](http://oitozero.github.io/ngSweetAlert/) 27 | - [http://t4t5.github.io/sweetalert/](http://t4t5.github.io/sweetalert/) 28 | -------------------------------------------------------------------------------- /SweetAlert.js: -------------------------------------------------------------------------------- 1 | /** 2 | @fileOverview 3 | 4 | @toc 5 | 6 | */ 7 | 8 | (function (root, factory) { 9 | "use strict"; 10 | 11 | /*global define*/ 12 | if (typeof define === 'function' && define.amd) { 13 | define(['angular', 'sweetalert'], factory); // AMD 14 | } else if (typeof module === 'object' && module.exports) { 15 | module.exports = factory(require('angular'), require('sweetalert')); // Node 16 | } else { 17 | factory(root.angular, root.swal); // Browser 18 | } 19 | 20 | }(this, function (angular, swal) { 21 | "use strict"; 22 | 23 | angular.module('oitozero.ngSweetAlert', []) 24 | .factory('SweetAlert', ['$rootScope', 'SweetAlertConfig', function ($rootScope, SweetAlertConfig) { 25 | //public methods 26 | var self = { 27 | 28 | swal: function (arg1, arg2, arg3) { 29 | 30 | //merge with default config 31 | var arg1 = angular.extend(SweetAlertConfig, arg1); 32 | 33 | $rootScope.$evalAsync(function () { 34 | if (typeof(arg2) === 'function') { 35 | swal(arg1, function (isConfirm) { 36 | $rootScope.$evalAsync(function () { 37 | arg2(isConfirm); 38 | }); 39 | }, arg3); 40 | } else { 41 | swal(arg1, arg2, arg3); 42 | } 43 | }); 44 | }, 45 | success: function (title, message) { 46 | $rootScope.$evalAsync(function () { 47 | swal(title, message, 'success'); 48 | }); 49 | }, 50 | error: function (title, message) { 51 | $rootScope.$evalAsync(function () { 52 | swal(title, message, 'error'); 53 | }); 54 | }, 55 | warning: function (title, message) { 56 | $rootScope.$evalAsync(function () { 57 | swal(title, message, 'warning'); 58 | }); 59 | }, 60 | info: function (title, message) { 61 | $rootScope.$evalAsync(function () { 62 | swal(title, message, 'info'); 63 | }); 64 | }, 65 | showInputError: function (message) { 66 | $rootScope.$evalAsync(function () { 67 | swal.showInputError(message); 68 | }); 69 | }, 70 | close: function () { 71 | $rootScope.$evalAsync(function () { 72 | swal.close(); 73 | }); 74 | } 75 | }; 76 | 77 | return self; 78 | }]).constant('SweetAlertConfig', { 79 | title: '', 80 | text: '', 81 | type: null, 82 | allowOutsideClick: false, 83 | showConfirmButton: true, 84 | showCancelButton: false, 85 | closeOnConfirm: true, 86 | closeOnCancel: true, 87 | confirmButtonText: 'OK', 88 | confirmButtonColor: '#8CD4F5', 89 | cancelButtonText: 'Cancel', 90 | imageUrl: null, 91 | imageSize: null, 92 | timer: null, 93 | customClass: '', 94 | html: false, 95 | animation: true, 96 | allowEscapeKey: true, 97 | inputType: 'text', 98 | inputPlaceholder: '', 99 | inputValue: '', 100 | showLoaderOnConfirm: false 101 | }); 102 | })); 103 | -------------------------------------------------------------------------------- /SweetAlert.min.js: -------------------------------------------------------------------------------- 1 | "use strict";angular.module("oitozero.ngSweetAlert",[]).factory("SweetAlert",["$rootScope",function($rootScope){var swal=window.swal,self={swal:function(arg1,arg2,arg3){$rootScope.$evalAsync(function(){"function"==typeof arg2?swal(arg1,function(isConfirm){$rootScope.$evalAsync(function(){arg2(isConfirm)})},arg3):swal(arg1,arg2,arg3)})},success:function(title,message){$rootScope.$evalAsync(function(){swal(title,message,"success")})},error:function(title,message){$rootScope.$evalAsync(function(){swal(title,message,"error")})},warning:function(title,message){$rootScope.$evalAsync(function(){swal(title,message,"warning")})},info:function(title,message){$rootScope.$evalAsync(function(){swal(title,message,"info")})},showInputError:function(message){$rootScope.$evalAsync(function(){swal.showInputError(message)})},close:function(){$rootScope.$evalAsync(function(){swal.close()})}};return self}]); 2 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ngSweetAlert", 3 | "version": "1.1.2", 4 | "main": "./SweetAlert.js", 5 | "author": "pedro@oitozero.com", 6 | "contributors": [ 7 | "gnick666@gmail.com", 8 | "thodoris.bais@gmail.com" 9 | ], 10 | "description": "AngularJS wrapper for SweetAlert", 11 | "keywords": [ 12 | "angular", 13 | "AngularJs", 14 | "sweetalert", 15 | "sweet", 16 | "alert" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "tests", 25 | "CHANGELOG.md" 26 | ], 27 | "dependencies": { 28 | "angular":">=1.3.0", 29 | "sweetalert": "1.*" 30 | }, 31 | "devDependencies": { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-sweetalert", 3 | "version": "1.1.2", 4 | "description": "AngularJS wrapper for SweetAlert", 5 | "main": "SweetAlert.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/oitozero/ngSweetAlert.git" 12 | }, 13 | "keywords": [ 14 | "angular", 15 | "AngularJs", 16 | "sweetalert", 17 | "sweet", 18 | "alert" 19 | ], 20 | "author": "pedro@oitozero.com", 21 | "contributors": [ 22 | "gnick666@gmail.com" 23 | ], 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/oitozero/ngSweetAlert/issues" 27 | }, 28 | "dependencies": { 29 | "angular": "^1.3.14", 30 | "sweetalert": "1.*" 31 | } 32 | } 33 | --------------------------------------------------------------------------------