├── .gitignore ├── LICENSE ├── README.md ├── bower.json └── src ├── app.js ├── complexModal.html ├── createDialog.js ├── index.html └── simpleModal.html /.gitignore: -------------------------------------------------------------------------------- 1 | # Webstorm 2 | \.idea 3 | 4 | 5 | # OS droppings 6 | .DS_Store 7 | .DS_Store? 8 | .Spotlight-V100 9 | .Trashes 10 | Icon? 11 | ehthumbs.db 12 | Thumbs.db 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | 3 | Copyright (C) 2011-2013 Vojta Jína. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation files 7 | (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angularjs-modal-service 2 | ======================= 3 | 4 | An AngularJS service that creates a Modal Popup with a given HTML template and controller. 5 | 6 | The Service createDialog can be used to create a modal using Twitter's Bootstrap on the fly. 7 | 8 | ## Requirements 9 | 10 | 1. Twitter Bootstrap CSS 11 | 2. the createDialog.js file 12 | 13 | ## Using it: 14 | 15 | ### Getting it via Bower 16 | 17 | 1. bower install angularjs-modal-service 18 | 19 | ### Getting it otherwise 20 | 21 | 1. Download createDialog.js and include it as part of your library 22 | 23 | ### Using it 24 | 25 | 1. Include the createDialog.js file in your index.html file. 26 | 2. Include the 'fundoo.services' as a module dependency when you define your app 27 | 3. Import the createDialog Service in your App Controller. 28 | 4. Call the createDialog() function from your controller, using the following syntax : 29 | 30 | ``` 31 | createDialog([template_url],{ 32 | id : [modal_id], 33 | title: [modal_title], 34 | backdrop: [backdrop_visible], 35 | success: [modal_success_button], 36 | cancel: [modal_cancel_button], 37 | controller: [modal_controller], 38 | backdropClass: [modal_backdrop_class], 39 | footerTemplate: [modal_footer_template], 40 | modalClass: [modal_class], 41 | css: { 42 | [css properties key: value] 43 | } 44 | }, {modal_custom_data}); 45 | ``` 46 | where, 47 | 48 | * **template_url** *[string]* : the url of the template of the body of the template. 49 | * **modal_id** *[string]* : the unique html id attr of the template. 50 | * **modal_title** *[string]* : is the title of the modal to be displayed in its header section. 51 | * **backdrop_visible(optional)** *[boolean]*: whether to hide the html page behind the modal under an overlay 52 | * **modal_success_button(optional)** *[object]*: the object add a submit button to the modal with its functionality 53 | 54 | *Syntax* 55 | ``` 56 | {label: '[label_of_button]', fn: '[function_on_click]'} 57 | ``` 58 | 59 | * **modal_cancel_button(optional)** *[object]*: the object add a cancel button to the modal with its functionality. For configuration options see modal_success_button 60 | * **modal_controller(optional)** *[string]* : is the controller attached to the modal. 61 | * **modal_backdrop_class(optional)** *[string]* : the css class for the backdrop of the modal. 62 | * **modal_footer_template(optional)** *[string]* : the footer template of the modal. 63 | * **modal_class(optional)** *[string]* : the css class for the modal. 64 | * **modal_custom_data(optional)** *[object]* : is an object where each key becomes an argument to the controller of the modal. 65 | 66 | ## Where can I see a demo? 67 | 68 | Glad you asked. Go check out our GitHub page for the [AngularJS-Modal-Service] 69 | 70 | ## Who are you? 71 | 72 | We are Fundoo Solutions, an awesome company based out of India who just love AngularJS. Check out our [website] or our [LinkedIn] page. 73 | 74 | ## License 75 | 76 | The code above is open sourced, and licensed under the MIT License, which is the simplest and easiest to understand, and most open. 77 | Basically, feel free to use this code or modify it as per your needs. The actual license can be found in the `LICENSE` file. 78 | 79 | 80 | [AngularJS-Modal-Service]: http://fundoo-solutions.github.io/angularjs-modal-service/ 81 | [website]: http://www.befundoo.com 82 | [LinkedIn]: http://www.linkedin.com/company/fundoo-solutions 83 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angularjs-modal-service", 3 | "version": "0.0.1", 4 | "main": "src/createDialog.js", 5 | "ignore": [ 6 | "**/.*", 7 | ".DS_Store", 8 | "node_modules", 9 | "components" 10 | ], 11 | "description": "An AngularJS service that creates a Modal Popup with a given HTML template and controller", 12 | "repository": { 13 | "type": "git", 14 | "url": "git@github.com:Fundoo-Solutions/angularjs-modal-service.git" 15 | }, 16 | 17 | "license": "MIT" 18 | } 19 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('FundooModalApp', ['fundoo.services']) 2 | .controller('MainCtrl', ['$scope', 'createDialog', function($scope, createDialogService) { 3 | $scope.launchInlineModal = function() { 4 | createDialogService({ 5 | id: 'simpleDialog', 6 | template: 7 | '
' +
12 | 'createDialog({\n' +
13 | ' id: "inlineDialog",\n' +
14 | ' template: "<div><!--template HTML here...--></div>"\n' +
15 | ' title: "A Inline Modal Dialog",\n' +
16 | ' backdrop: true,\n' +
17 | ' success: {\n' +
18 | ' label: "Yay",\n' +
19 | ' fn: function(){\n' +
20 | ' console.log("Inline modal closed");\n' +
21 | ' }\n' +
22 | ' }\n' +
23 | '});\n' +
24 | '
\n' +
25 | ' ' +
42 | 'createDialog({\n' +
43 | ' id: "objectDialog",\n' +
44 | ' template: angular.element("...")\n' +
45 | ' title: "A Object Modal Dialog",\n' +
46 | ' backdrop: true,\n' +
47 | ' success: {\n' +
48 | ' label: "Yay",\n' +
49 | ' fn: function(){\n' +
50 | ' console.log("Object modal closed");\n' +
51 | ' }\n' +
52 | ' }\n' +
53 | '});\n' +
54 | '
\n' +
55 | ' 6 | createDialog('complexModal.html',{ 7 | id : 'complexDialog', 8 | title: 'A Complex Modal Dialog', 9 | backdrop: true, 10 | success: { 11 | label: 'Yay', 12 | fn: function() { 13 | console.log('Complex modal closed'); 14 | } 15 | }, 16 | controller: 'ComplexModalController' 17 | },{ 18 | myVal: 15, 19 | assetDetails: { 20 | name: 'My Asset', 21 | description: 'A Very Nice Asset' 22 | } 23 | }); 24 |25 |
6 | createDialog('simpleModal.html', {
7 | id : 'simpleDialog',
8 | title: 'A Simple Modal Dialog',
9 | backdrop: true,
10 | success: {
11 | label: 'Yay',
12 | fn: function(){
13 | console.log('Simple modal closed');
14 | }
15 | }
16 | });
17 |
18 |