├── FUNDING.yml ├── .gitignore ├── branding ├── dirty-forms-icon.png ├── dirty-forms-icon.psd ├── dirty-forms-logo.png └── dirty-forms-logo.psd ├── tests ├── process.php ├── modal_form.html └── env.html ├── helpers ├── alwaysdirty.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── tinymce.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── ckeditor.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── alwaysdirty.js ├── ckeditor.js └── tinymce.js ├── pkg ├── bower.json ├── package.json └── nuget.nuspec ├── dialogs ├── facebox.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── blockui.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── jquery-ui.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── pnotify.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── bootstrap.pkg │ ├── bower.json │ ├── package.json │ ├── nuget.nuspec │ └── README.md ├── jquery-ui.js ├── blockui.js ├── bootstrap.js ├── facebox.js └── pnotify.js ├── LICENSE ├── .gitmodules ├── package.json ├── CONTRIBUTING.md ├── RELEASING.md ├── gulpfile.js └── jquery.dirtyforms.js /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [NightOwl888] 2 | custom: ["https://www.paypal.me/ShadStorhaug"] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # git ignore file 2 | 3 | /node_modules 4 | *.nupkg 5 | *.tgz 6 | /[Nn]u[Gg]et.* -------------------------------------------------------------------------------- /branding/dirty-forms-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snikch/jquery.dirtyforms/HEAD/branding/dirty-forms-icon.png -------------------------------------------------------------------------------- /branding/dirty-forms-icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snikch/jquery.dirtyforms/HEAD/branding/dirty-forms-icon.psd -------------------------------------------------------------------------------- /branding/dirty-forms-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snikch/jquery.dirtyforms/HEAD/branding/dirty-forms-logo.png -------------------------------------------------------------------------------- /branding/dirty-forms-logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snikch/jquery.dirtyforms/HEAD/branding/dirty-forms-logo.psd -------------------------------------------------------------------------------- /tests/process.php: -------------------------------------------------------------------------------- 1 |
2 | 
7 | 
8 | -------------------------------------------------------------------------------- /tests/modal_form.html: -------------------------------------------------------------------------------- 1 |
2 | 4 |

5 |
6 |

Me, I'm just a link somewhere

7 | -------------------------------------------------------------------------------- /helpers/alwaysdirty.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.alwaysdirty", 3 | "main": "jquery.dirtyforms.helpers.alwaysdirty.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Mal Curtis " 8 | ], 9 | "description": "A helper to force forms to always be dirty when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "dirty", 12 | "forms", 13 | "HTML", 14 | "form", 15 | "confirm", 16 | "dialog", 17 | "confirmation", 18 | "are", 19 | "you", 20 | "sure" 21 | ], 22 | "license": "MIT", 23 | "ignore": [ 24 | "**/.*", 25 | "node_modules", 26 | "bower_components", 27 | "*.json", 28 | ".git" 29 | ], 30 | "dependencies": { 31 | "jquery.dirtyforms": ">=1.0.0" 32 | } 33 | } -------------------------------------------------------------------------------- /helpers/tinymce.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.tinymce", 3 | "main": "jquery.dirtyforms.helpers.tinymce.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Mal Curtis " 8 | ], 9 | "description": "A helper to enable TinyMCE support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "tinymce", 12 | "dirty", 13 | "forms", 14 | "HTML", 15 | "form", 16 | "confirm", 17 | "dialog", 18 | "confirmation", 19 | "are", 20 | "you", 21 | "sure" 22 | ], 23 | "license": "MIT", 24 | "ignore": [ 25 | "**/.*", 26 | "node_modules", 27 | "bower_components", 28 | "*.json", 29 | ".git" 30 | ], 31 | "dependencies": { 32 | "jquery.dirtyforms": ">=1.0.0", 33 | "tinymce": ">=4.0.0" 34 | } 35 | } -------------------------------------------------------------------------------- /helpers/ckeditor.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.ckeditor", 3 | "main": "jquery.dirtyforms.helpers.ckeditor.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Mal Curtis " 8 | ], 9 | "description": "A helper to enable CKEditor support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "ckeditor", 12 | "dirty", 13 | "forms", 14 | "HTML", 15 | "form", 16 | "confirm", 17 | "dialog", 18 | "confirmation", 19 | "are", 20 | "you", 21 | "sure" 22 | ], 23 | "license": "MIT", 24 | "ignore": [ 25 | "**/.*", 26 | "node_modules", 27 | "bower_components", 28 | "*.json", 29 | ".git" 30 | ], 31 | "dependencies": { 32 | "jquery.dirtyforms": ">=1.0.0", 33 | "ckeditor": ">=4.3.3" 34 | } 35 | } -------------------------------------------------------------------------------- /pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms", 3 | "main": "jquery.dirtyforms.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Mal Curtis ", 8 | "Shad Storhaug ", 9 | "Nick Coyne " 10 | ], 11 | "description": "A jQuery Plugin that monitors forms for change and alerts the user before leaving the page.", 12 | "keywords": [ 13 | "dirty", 14 | "forms", 15 | "HTML", 16 | "form", 17 | "confirm", 18 | "dialog", 19 | "confirmation", 20 | "are", 21 | "you", 22 | "sure" 23 | ], 24 | "license": "MIT", 25 | "ignore": [ 26 | "**/.*", 27 | "node_modules", 28 | "bower_components", 29 | "*.json", 30 | ".git" 31 | ], 32 | "dependencies": { 33 | "jquery": ">= 1.4.2" 34 | } 35 | } -------------------------------------------------------------------------------- /dialogs/facebox.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.facebox", 3 | "main": "jquery.dirtyforms.dialogs.facebox.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Shad Storhaug " 8 | ], 9 | "description": "A module to enable automatic Facebox dialog support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "facebox", 12 | "dirty", 13 | "forms", 14 | "HTML", 15 | "form", 16 | "confirm", 17 | "dialog", 18 | "confirmation", 19 | "are", 20 | "you", 21 | "sure" 22 | ], 23 | "license": "MIT", 24 | "ignore": [ 25 | "**/.*", 26 | "node_modules", 27 | "bower_components", 28 | "*.json", 29 | ".git" 30 | ], 31 | "dependencies": { 32 | "jquery.dirtyforms": ">=1.0.0", 33 | "jquery.facebox": ">=1.4.1" 34 | } 35 | } -------------------------------------------------------------------------------- /dialogs/blockui.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.blockui", 3 | "main": "jquery.dirtyforms.dialogs.blockui.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Shad Storhaug " 8 | ], 9 | "description": "A module to enable automatic BlockUI dialog support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "blockui", 12 | "dirty", 13 | "forms", 14 | "HTML", 15 | "form", 16 | "confirm", 17 | "dialog", 18 | "confirmation", 19 | "are", 20 | "you", 21 | "sure" 22 | ], 23 | "license": "MIT", 24 | "ignore": [ 25 | "**/.*", 26 | "node_modules", 27 | "bower_components", 28 | "*.json", 29 | ".git" 30 | ], 31 | "dependencies": { 32 | "jquery": ">=1.7.0", 33 | "jquery.dirtyforms": ">=1.0.0", 34 | "blockui": "latest" 35 | } 36 | } -------------------------------------------------------------------------------- /dialogs/jquery-ui.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.jquery-ui", 3 | "main": "jquery.dirtyforms.dialogs.jquery-ui.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Shad Storhaug " 8 | ], 9 | "description": "A module to enable automatic jQuery UI dialog support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "ui", 12 | "jquery", 13 | "dirty", 14 | "forms", 15 | "HTML", 16 | "form", 17 | "confirm", 18 | "dialog", 19 | "confirmation", 20 | "are", 21 | "you", 22 | "sure" 23 | ], 24 | "license": "MIT", 25 | "ignore": [ 26 | "**/.*", 27 | "node_modules", 28 | "bower_components", 29 | "*.json", 30 | ".git" 31 | ], 32 | "dependencies": { 33 | "jquery.dirtyforms": ">=1.0.0", 34 | "jquery-ui": ">=1.11.2" 35 | } 36 | } -------------------------------------------------------------------------------- /dialogs/pnotify.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.pnotify", 3 | "main": "jquery.dirtyforms.dialogs.pnotify.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Shad Storhaug " 8 | ], 9 | "description": "A module to enable automatic PNotify dialog support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "pnotify", 12 | "dirty", 13 | "forms", 14 | "HTML", 15 | "form", 16 | "confirm", 17 | "dialog", 18 | "confirmation", 19 | "are", 20 | "you", 21 | "sure" 22 | ], 23 | "license": "MIT", 24 | "ignore": [ 25 | "**/.*", 26 | "node_modules", 27 | "bower_components", 28 | "*.json", 29 | ".git" 30 | ], 31 | "dependencies": { 32 | "jquery": ">=1.6.4", 33 | "jquery.dirtyforms": ">=1.0.0", 34 | "pnotify": ">=1.3" 35 | } 36 | } -------------------------------------------------------------------------------- /dialogs/bootstrap.pkg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.bootstrap", 3 | "main": "jquery.dirtyforms.dialogs.bootstrap.min.js", 4 | "version": "2.0.0", 5 | "homepage": "https://github.com/snikch/jquery.dirtyforms", 6 | "authors": [ 7 | "Shad Storhaug " 8 | ], 9 | "description": "A module to enable automatic Bootstrap Modal dialog support when using jQuery Dirty Forms.", 10 | "keywords": [ 11 | "bootstrap", 12 | "modal", 13 | "dirty", 14 | "forms", 15 | "HTML", 16 | "form", 17 | "confirm", 18 | "dialog", 19 | "confirmation", 20 | "are", 21 | "you", 22 | "sure" 23 | ], 24 | "license": "MIT", 25 | "ignore": [ 26 | "**/.*", 27 | "node_modules", 28 | "bower_components", 29 | "*.json", 30 | ".git" 31 | ], 32 | "dependencies": { 33 | "jquery": ">=1.9.1", 34 | "jquery.dirtyforms": ">=1.0.0", 35 | "bootstrap": ">=3.0.0" 36 | } 37 | } -------------------------------------------------------------------------------- /pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms", 3 | "version": "2.0.0", 4 | "description": "Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms.", 5 | "main": "jquery.dirtyforms.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery": ">=1.4.2" 12 | }, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/snikch/jquery.dirtyforms.git" 19 | }, 20 | "keywords": [ 21 | "jquery", 22 | "plugin", 23 | "dirty", 24 | "forms", 25 | "confirmation", 26 | "validate", 27 | "validation", 28 | "areyousure", 29 | "jquery-plugin", 30 | "ecosystem:jquery" 31 | ], 32 | "author": "Mal Curtis ", 33 | "license": "MIT", 34 | "bugs": { 35 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 36 | }, 37 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 by Mal Curtis 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /helpers/alwaysdirty.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.alwaysdirty", 3 | "version": "2.0.0", 4 | "description": "A helper to force forms to always be dirty when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.helpers.alwaysdirty.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.helpers.alwaysdirty.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery.dirtyforms": ">=1.0.0" 12 | }, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 19 | }, 20 | "keywords": [ 21 | "jquery", 22 | "plugin", 23 | "dirty", 24 | "forms", 25 | "confirmation", 26 | "validate", 27 | "validation", 28 | "areyousure", 29 | "jquery-plugin", 30 | "ecosystem:jquery" 31 | ], 32 | "author": "Mal Curtis ", 33 | "license": "MIT", 34 | "bugs": { 35 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 36 | }, 37 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 38 | } 39 | -------------------------------------------------------------------------------- /helpers/tinymce.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.tinymce", 3 | "version": "2.0.0", 4 | "description": "A helper to enable TinyMCE support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.helpers.tinymce.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.helpers.tinymce.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery.dirtyforms": ">=1.0.0", 12 | "tinymce": ">=4.0.25" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 20 | }, 21 | "keywords": [ 22 | "tinymce", 23 | "jquery", 24 | "plugin", 25 | "dirty", 26 | "forms", 27 | "confirmation", 28 | "validate", 29 | "validation", 30 | "areyousure", 31 | "jquery-plugin", 32 | "ecosystem:jquery" 33 | ], 34 | "author": "Mal Curtis ", 35 | "license": "MIT", 36 | "bugs": { 37 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 38 | }, 39 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 40 | } 41 | -------------------------------------------------------------------------------- /helpers/ckeditor.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.helpers.ckeditor", 3 | "version": "2.0.0", 4 | "description": "A helper to enable CKEditor support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.helpers.ckeditor.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.helpers.ckeditor.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery.dirtyforms": ">=1.0.0", 12 | "ckeditor-dev": ">=4.3.3" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 20 | }, 21 | "keywords": [ 22 | "ckeditor", 23 | "jquery", 24 | "plugin", 25 | "dirty", 26 | "forms", 27 | "confirmation", 28 | "validate", 29 | "validation", 30 | "areyousure", 31 | "jquery-plugin", 32 | "ecosystem:jquery" 33 | ], 34 | "author": "Mal Curtis ", 35 | "license": "MIT", 36 | "bugs": { 37 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 38 | }, 39 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 40 | } 41 | -------------------------------------------------------------------------------- /dialogs/facebox.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.facebox", 3 | "version": "2.0.0", 4 | "description": "A module to enable automatic Facebox dialog support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.dialogs.facebox.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.dialogs.facebox.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery.dirtyforms": ">=1.0.0", 12 | "jquery.facebox": ">=1.4.1" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 20 | }, 21 | "keywords": [ 22 | "facebox", 23 | "jquery", 24 | "plugin", 25 | "dirty", 26 | "forms", 27 | "confirmation", 28 | "validate", 29 | "validation", 30 | "areyousure", 31 | "jquery-plugin", 32 | "ecosystem:jquery" 33 | ], 34 | "author": "Shad Storhaug ", 35 | "license": "MIT", 36 | "bugs": { 37 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 38 | }, 39 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 40 | } 41 | -------------------------------------------------------------------------------- /dialogs/jquery-ui.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.jquery-ui", 3 | "version": "2.0.0", 4 | "description": "A module to enable automatic jQuery UI dialog support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.dialogs.jquery-ui.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.dialogs.jquery-ui.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery.dirtyforms": ">=1.0.0", 12 | "jquery-ui": ">=1.10.5" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 20 | }, 21 | "keywords": [ 22 | "ui", 23 | "jquery", 24 | "plugin", 25 | "dirty", 26 | "forms", 27 | "confirmation", 28 | "validate", 29 | "validation", 30 | "areyousure", 31 | "jquery-plugin", 32 | "ecosystem:jquery" 33 | ], 34 | "author": "Shad Storhaug ", 35 | "license": "MIT", 36 | "bugs": { 37 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 38 | }, 39 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 40 | } 41 | -------------------------------------------------------------------------------- /dialogs/pnotify.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.pnotify", 3 | "version": "2.0.0", 4 | "description": "A module to enable automatic PNotify dialog support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.dialogs.pnotify.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.dialogs.pnotify.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery": ">=1.6.4", 12 | "jquery.dirtyforms": ">=1.0.0", 13 | "pnotify": ">=1.3" 14 | }, 15 | "scripts": { 16 | "test": "echo \"Error: no test specified\" && exit 1" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 21 | }, 22 | "keywords": [ 23 | "pnotify", 24 | "jquery", 25 | "plugin", 26 | "dirty", 27 | "forms", 28 | "confirmation", 29 | "validate", 30 | "validation", 31 | "areyousure", 32 | "jquery-plugin", 33 | "ecosystem:jquery" 34 | ], 35 | "author": "Shad Storhaug ", 36 | "license": "MIT", 37 | "bugs": { 38 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 39 | }, 40 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 41 | } 42 | -------------------------------------------------------------------------------- /dialogs/blockui.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.blockui", 3 | "version": "2.0.0", 4 | "description": "A module to enable automatic BlockUI dialog support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.dialogs.blockui.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.dialogs.blockui.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery": ">=1.7.0", 12 | "jquery.dirtyforms": ">=1.0.0", 13 | "block-ui": ">=2.70.0" 14 | }, 15 | "scripts": { 16 | "test": "echo \"Error: no test specified\" && exit 1" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 21 | }, 22 | "keywords": [ 23 | "blockui", 24 | "jquery", 25 | "plugin", 26 | "dirty", 27 | "forms", 28 | "confirmation", 29 | "validate", 30 | "validation", 31 | "areyousure", 32 | "jquery-plugin", 33 | "ecosystem:jquery" 34 | ], 35 | "author": "Shad Storhaug ", 36 | "license": "MIT", 37 | "bugs": { 38 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 39 | }, 40 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 41 | } 42 | -------------------------------------------------------------------------------- /dialogs/bootstrap.pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms.dialogs.bootstrap", 3 | "version": "2.0.0", 4 | "description": "A module to enable automatic Bootstrap Modal dialog support when using jQuery Dirty Forms.", 5 | "main": "jquery.dirtyforms.dialogs.bootstrap.min.js", 6 | "files": [ 7 | "jquery.dirtyforms.dialogs.bootstrap.*", 8 | "LICENSE*" 9 | ], 10 | "dependencies": { 11 | "jquery": ">=1.9.1", 12 | "jquery.dirtyforms": ">=1.0.0", 13 | "bootstrap": ">=3.0.0" 14 | }, 15 | "scripts": { 16 | "test": "echo \"Error: no test specified\" && exit 1" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/snikch/jquery.dirtyforms.git" 21 | }, 22 | "keywords": [ 23 | "bootstrap", 24 | "modal", 25 | "jquery", 26 | "plugin", 27 | "dirty", 28 | "forms", 29 | "confirmation", 30 | "validate", 31 | "validation", 32 | "areyousure", 33 | "jquery-plugin", 34 | "ecosystem:jquery" 35 | ], 36 | "author": "Shad Storhaug ", 37 | "license": "MIT", 38 | "bugs": { 39 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 40 | }, 41 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 42 | } 43 | -------------------------------------------------------------------------------- /pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms 5 | jQuery Dirty Forms 6 | $version$ 7 | snikch, NightOwl888, Nitrodust, ssmiley483, gmcrist, hleumas 8 | false 9 | Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /dialogs/facebox.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.dialogs.facebox 5 | Facebox dialog for jQuery Dirty Forms 6 | $version$ 7 | NightOwl888 8 | false 9 | A module to enable automatic Facebox dialog support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | facebox jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /helpers/alwaysdirty.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.helpers.alwaysdirty 5 | Always dirty helper for jQuery Dirty Forms 6 | $version$ 7 | snikch, NightOwl888, Nitrodust, ssmiley483, gmcrist, hleumas 8 | false 9 | A helper to force forms to always be dirty when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | always dirty jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /dialogs/jquery-ui.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.dialogs.jquery-ui 5 | jQuery UI dialog for jQuery Dirty Forms 6 | $version$ 7 | NightOwl888 8 | false 9 | A module to enable automatic jQuery UI dialog support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | jquery ui plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /helpers/tinymce.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.helpers.tinymce 5 | TinyMCE helper for jQuery Dirty Forms 6 | $version$ 7 | snikch, NightOwl888, Nitrodust, ssmiley483, gmcrist, hleumas 8 | false 9 | A helper to enable TinyMCE support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | tinymce jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /helpers/ckeditor.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.helpers.ckeditor 5 | CKEditor helper for jQuery Dirty Forms 6 | $version$ 7 | snikch, NightOwl888, Nitrodust, ssmiley483, gmcrist, hleumas 8 | false 9 | A helper to enable CKEditor support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | ckeditor jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /dialogs/pnotify.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.dialogs.pnotify 5 | PNotify dialog for jQuery Dirty Forms 6 | $version$ 7 | NightOwl888 8 | false 9 | A module to enable automatic PNotify dialog support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | pnotify jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /dialogs/blockui.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.dialogs.blockui 5 | BlockUI dialog for jQuery Dirty Forms 6 | $version$ 7 | NightOwl888 8 | false 9 | A module to enable automatic BlockUI dialog support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | blockui jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dist/jquery.dirtyforms"] 2 | path = dist/jquery.dirtyforms 3 | url = https://github.com/NightOwl888/jquery.dirtyforms.dist.git 4 | [submodule "dist/jquery.dirtyforms.helpers.alwaysdirty"] 5 | path = dist/jquery.dirtyforms.helpers.alwaysdirty 6 | url = https://github.com/NightOwl888/jquery.dirtyforms.helpers.alwaysdirty.dist.git 7 | [submodule "dist/jquery.dirtyforms.helpers.ckeditor"] 8 | path = dist/jquery.dirtyforms.helpers.ckeditor 9 | url = https://github.com/NightOwl888/jquery.dirtyforms.helpers.ckeditor.dist.git 10 | [submodule "dist/jquery.dirtyforms.helpers.tinymce"] 11 | path = dist/jquery.dirtyforms.helpers.tinymce 12 | url = https://github.com/NightOwl888/jquery.dirtyforms.helpers.tinymce.dist.git 13 | [submodule "dist/jquery.dirtyforms.dialogs.blockui"] 14 | path = dist/jquery.dirtyforms.dialogs.blockui 15 | url = https://github.com/NightOwl888/jquery.dirtyforms.dialogs.blockui.dist.git 16 | [submodule "dist/jquery.dirtyforms.dialogs.facebox"] 17 | path = dist/jquery.dirtyforms.dialogs.facebox 18 | url = https://github.com/NightOwl888/jquery.dirtyforms.dialogs.facebox.dist.git 19 | [submodule "dist/jquery.dirtyforms.dialogs.jquery-ui"] 20 | path = dist/jquery.dirtyforms.dialogs.jquery-ui 21 | url = https://github.com/NightOwl888/jquery.dirtyforms.dialogs.jquery-ui.dist.git 22 | [submodule "dist/jquery.dirtyforms.dialogs.pnotify"] 23 | path = dist/jquery.dirtyforms.dialogs.pnotify 24 | url = https://github.com/NightOwl888/jquery.dirtyforms.dialogs.pnotify.dist.git 25 | [submodule "dist/jquery.dirtyforms.dialogs.bootstrap"] 26 | path = dist/jquery.dirtyforms.dialogs.bootstrap 27 | url = https://github.com/NightOwl888/jquery.dirtyforms.dialogs.bootstrap.dist.git 28 | -------------------------------------------------------------------------------- /dialogs/bootstrap.pkg/nuget.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jquery.dirtyforms.dialogs.bootstrap 5 | Bootstrap Modal dialog for jQuery Dirty Forms 6 | $version$ 7 | NightOwl888 8 | false 9 | A module to enable automatic Bootstrap Modal dialog support when using jQuery Dirty Forms. 10 | Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons. 11 | en-US 12 | bootstrap modal jquery plugin dirty forms confirmation validate validation areyousure 13 | https://github.com/snikch/jquery.dirtyforms 14 | https://github.com/snikch/jquery.dirtyforms/blob/master/LICENSE 15 | https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-icon.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.dirtyforms", 3 | "version": "2.0.0", 4 | "description": "Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms.", 5 | "main": "jquery.dirtyforms.js", 6 | "files": [ 7 | "jquery.dirtyforms.js" 8 | ], 9 | "dependencies": { 10 | "jquery": ">=1.4.2" 11 | }, 12 | "devDependencies": { 13 | "del": "^1.2.0", 14 | "fs": "^0.0.2", 15 | "glob": "^5.0.10", 16 | "gulp": "3.8.11", 17 | "gulp-bump": "^0.3.1", 18 | "gulp-git": "^1.2.4", 19 | "gulp-if": "^1.2.5", 20 | "gulp-ignore": "^1.2.1", 21 | "gulp-jshint": "^1.11.0", 22 | "gulp-rename": "^1.2.2", 23 | "gulp-replace": "^0.5.3", 24 | "gulp-sourcemaps": "^1.5.2", 25 | "gulp-tap": "^0.1.3", 26 | "gulp-uglify": "^1.2.0", 27 | "jshint-stylish": "^2.0.0", 28 | "lazypipe": "^1.0.1", 29 | "merge-stream": "^0.1.7", 30 | "path": "^0.11.14", 31 | "request": "^2.55.0", 32 | "run-sequence": "^1.1.0", 33 | "shelljs": "^0.5.1", 34 | "yargs": "^3.7.2" 35 | }, 36 | "scripts": { 37 | "test": "./node_modules/.bin/gulp test" 38 | }, 39 | "repository": { 40 | "type": "git", 41 | "url": "https://github.com/snikch/jquery.dirtyforms.git" 42 | }, 43 | "keywords": [ 44 | "jquery", 45 | "plugin", 46 | "dirty", 47 | "forms", 48 | "confirmation", 49 | "validate", 50 | "validation", 51 | "areyousure", 52 | "jquery-plugin", 53 | "ecosystem:jquery" 54 | ], 55 | "author": "Mal Curtis ", 56 | "license": "MIT", 57 | "bugs": { 58 | "url": "https://github.com/snikch/jquery.dirtyforms/issues" 59 | }, 60 | "homepage": "https://github.com/snikch/jquery.dirtyforms#readme" 61 | } 62 | -------------------------------------------------------------------------------- /helpers/alwaysdirty.js: -------------------------------------------------------------------------------- 1 | /*! 2 | Always dirty helper module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2012-2016 Mal Curtis 4 | License MIT 5 | */ 6 | 7 | // Example helper, the form is always considered dirty 8 | 9 | /**/ 10 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 11 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 12 | (function (factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['jquery', 'window', 'document'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // Node/CommonJS 18 | module.exports = factory(require('jquery'), window, document); 19 | } else { 20 | // Browser globals 21 | factory(jQuery, window, document); 22 | } 23 | }(function ($, window, document, undefined) { 24 | /**/ 25 | // Can't use ECMAScript 5's strict mode because several apps 26 | // including ASP.NET trace the stack via arguments.caller.callee 27 | // and Firefox dies if you try to trace through "use strict" call chains. 28 | // See jQuery issue (#13335) 29 | // Support: Firefox 18+ 30 | //"use strict"; 31 | 32 | // Create a new object, with an isDirty method 33 | var alwaysDirty = { 34 | isDirty: function (node) { 35 | // Perform dirty check on a given node (usually a form element) 36 | return true; 37 | } 38 | }; 39 | // Push the new object onto the helpers array 40 | $.DirtyForms.helpers.push(alwaysDirty); 41 | 42 | /**/ 43 | })); 44 | /**/ 45 | -------------------------------------------------------------------------------- /helpers/ckeditor.js: -------------------------------------------------------------------------------- 1 | /*! 2 | CkEditor helper module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2012-2016 Mal Curtis 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | var ignoreSelector = '.cke_dialog_ui_button,.cke_tpl_list a'; 31 | 32 | var ckeditor = { 33 | ignoreSelector: ignoreSelector, 34 | isDirty: function ($form) { 35 | var $editors = ckeditors($form), 36 | isDirty = false; 37 | if ($editors.length > 0) { 38 | $.DirtyForms.dirtylog('Checking ' + $editors.length + ' ckeditors for dirtyness.'); 39 | $editors.each(function (editorIndex) { 40 | if (this.checkDirty()) { 41 | isDirty = true; 42 | 43 | $.DirtyForms.dirtylog('CKEditor with index ' + editorIndex + ' was dirty, exiting...'); 44 | // Return false to break out of the .each() function 45 | return false; 46 | } 47 | }); 48 | } 49 | return isDirty; 50 | }, 51 | setClean: function ($form) { 52 | ckeditors($form).each(function () { this.resetDirty(); }); 53 | }, 54 | 55 | // Support for Dirty Forms < 2.0 56 | ignoreAnchorSelector: ignoreSelector 57 | }; 58 | var ckeditors = function (form) { 59 | var $form = form.jquery ? form : $(form); 60 | var editors = []; 61 | if (!window.CKEDITOR || !window.CKEDITOR.instances) { 62 | return $(editors); 63 | } 64 | try { 65 | for (var key in window.CKEDITOR.instances) { 66 | if (window.CKEDITOR.instances.hasOwnProperty(key)) { 67 | var editor = window.CKEDITOR.instances[key]; 68 | if ($(editor.element.$).parents().index($form) != -1) { 69 | $.DirtyForms.dirtylog('Adding CKEditor with key ' + key); 70 | editors.push(editor); 71 | } 72 | } 73 | } 74 | } 75 | catch (e) { 76 | // Ignore, means there was no CKEDITOR variable 77 | } 78 | return $(editors); 79 | }; 80 | $.DirtyForms.helpers.push(ckeditor); 81 | 82 | /**/ 83 | })); 84 | /**/ 85 | -------------------------------------------------------------------------------- /dialogs/jquery-ui.js: -------------------------------------------------------------------------------- 1 | /*! 2 | jQuery UI dialog module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2015-2016 Shad Storhaug 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | // Create a local reference for simplicity 31 | var $dialog = $('
'); 32 | $('body').append($dialog); 33 | 34 | $.DirtyForms.dialog = { 35 | // Custom properties and methods to allow overriding (may differ per dialog) 36 | title: 'Are you sure you want to do that?', 37 | proceedButtonText: 'Leave This Page', 38 | stayButtonText: 'Stay Here', 39 | preMessageText: '', 40 | postMessageText: '', 41 | width: 430, 42 | 43 | // Typical Dirty Forms Properties and Methods 44 | open: function (choice, message) { 45 | var commit = choice.isDF1 ? $.DirtyForms.choiceCommit : choice.commit; 46 | 47 | $dialog.dialog({ 48 | open: function () { 49 | // Set the focus on close button 50 | $(this).parents('.ui-dialog').find('.ui-dialog-buttonpane button:eq(1)').focus(); 51 | }, 52 | close: commit, 53 | title: this.title, 54 | width: this.width, 55 | modal: true, 56 | buttons: [ 57 | { 58 | text: this.proceedButtonText, 59 | click: function () { 60 | choice.proceed = $.DirtyForms.choiceContinue = true; 61 | $(this).dialog('close'); 62 | } 63 | }, 64 | { 65 | text: this.stayButtonText, 66 | click: function () { 67 | $(this).dialog('close'); 68 | } 69 | } 70 | ] 71 | }); 72 | $dialog.html(this.preMessageText + message + this.postMessageText); 73 | 74 | // Support for Dirty Forms < 2.0 75 | if (choice.isDF1) { 76 | var onEscKey = function (e) { 77 | if (e.which == 27) { 78 | e.preventDefault(); 79 | $dialog.dialog('close'); 80 | return false; 81 | } 82 | }; 83 | 84 | // Trap the escape key and force a close. Cancel it so jQuery UI doesn't intercept it. 85 | // This will fire the dialogclose event to commit the choice (which defaults to false). 86 | $(document).unbind('keydown', onEscKey).keydown(onEscKey); 87 | } 88 | }, 89 | close: function () { 90 | $dialog.dialog('close'); 91 | }, 92 | 93 | // Support for Dirty Forms < 2.0 94 | fire: function (message, title) { 95 | this.title = title; 96 | this.open({ isDF1: true }, message); 97 | }, 98 | 99 | // Support for Dirty Forms < 1.2 100 | bind: function () { 101 | }, 102 | stash: function () { 103 | return false; 104 | }, 105 | refire: function () { 106 | return false; 107 | }, 108 | selector: 'no-op' 109 | }; 110 | 111 | /**/ 112 | })); 113 | /**/ 114 | -------------------------------------------------------------------------------- /dialogs/blockui.js: -------------------------------------------------------------------------------- 1 | /*! 2 | BlockUI dialog module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2015-2016 Shad Storhaug 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | $.DirtyForms.dialog = { 31 | // Custom properties and methods to allow overriding (may differ per dialog) 32 | title: 'Are you sure you want to do that?', 33 | class: 'dirty-dialog', 34 | proceedButtonText: 'Leave This Page', 35 | stayButtonText: 'Stay Here', 36 | width: '400px', 37 | padding: '10px', 38 | color: '#000', 39 | border: '3px solid #aaa', 40 | backgroundColor: '#fff', 41 | overlayOpacity: 0.5, 42 | 43 | // Typical Dirty Forms Properties and Methods 44 | open: function (choice, message) { 45 | $.blockUI({ 46 | message: '' + 47 | '

' + this.title + '

' + 48 | '

' + message + '

' + 49 | '' + 50 | ' ' + 51 | '' + 52 | '' + 53 | '
', 54 | css: { 55 | width: this.width, 56 | padding: this.padding, 57 | color: this.color, 58 | border: this.border, 59 | backgroundColor: this.backgroundColor, 60 | cursor: 'auto' 61 | }, 62 | overlayCSS: { 63 | cursor: 'auto', 64 | opacity: this.overlayOpacity 65 | } 66 | }); 67 | 68 | // Bind Events 69 | choice.bindEnterKey = true; 70 | choice.proceedSelector = '.' + this.class + ' .dirty-proceed'; 71 | choice.staySelector = '.' + this.class + ' .dirty-stay,.blockOverlay'; 72 | 73 | // Support for Dirty Forms < 2.0 74 | if (choice.isDF1) { 75 | var close = function (decision) { 76 | return function (e) { 77 | if (e.type !== 'keydown' || (e.type === 'keydown' && (e.which == 27 || e.which == 13))) { 78 | $.unblockUI(); 79 | decision(e); 80 | return false; 81 | } 82 | }; 83 | }; 84 | var decidingCancel = $.DirtyForms.decidingCancel; 85 | $(document).keydown(close(decidingCancel)); 86 | $(choice.staySelector).click(close(decidingCancel)); 87 | $(choice.proceedSelector).click(close($.DirtyForms.decidingContinue)); 88 | } 89 | }, 90 | close: function () { 91 | $.unblockUI(); 92 | }, 93 | 94 | // Support for Dirty Forms < 2.0 95 | fire: function (message, title) { 96 | this.title = title; 97 | this.open({ isDF1: true }, message); 98 | }, 99 | 100 | // Support for Dirty Forms < 1.2 101 | bind: function () { 102 | }, 103 | stash: function () { 104 | return false; 105 | }, 106 | refire: function () { 107 | return false; 108 | }, 109 | selector: 'no-op' 110 | }; 111 | 112 | /**/ 113 | })); 114 | /**/ 115 | -------------------------------------------------------------------------------- /helpers/alwaysdirty.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.helpers.alwaysdirty 6 | 7 | This is a helper module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This helper causes Dirty Forms to always show a dirty status, effectively overriding the logic that causes the form 12 | to be dirty when one of the input or select HTML controls is updated. It was primarily written to demonstrate 13 | how to write a custom helper, but may also be helpful in real-world scenarios where you don't want the user to navigate 14 | from the page without their explicit consent. 15 | 16 | ## Prerequisites 17 | 18 | Prerequesites must be included in this order: 19 | 20 | - [jQuery](http://jquery.com) (>= 1.4.2) 21 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) 22 | 23 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 24 | 25 | ## Download & Installation 26 | There are several different ways to get the code. Some examples below: 27 | 28 | #### CDN 29 | The Always Dirty helper is available over jsDelivr CDN and can directly be included on every page. 30 | ```HTML 31 | 32 | ``` 33 | 34 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, jquery.dirtyforms, and jquery.dirtyforms.helpers.alwaysdirty in one request. 35 | ```HTML 36 | 37 | ``` 38 | 39 | #### Self-Hosted 40 | Download and save one of two available files to include the Always Dirty helper to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.alwaysdirty.dist/master/jquery.dirtyforms.helpers.alwaysdirty.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.alwaysdirty.dist/master/jquery.dirtyforms.helpers.alwaysdirty.min.js) version. 41 | ```HTML 42 | 43 | ``` 44 | 45 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 46 | 47 | #### Package Managers 48 | The Always Dirty helper is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the helper, including all dependencies. 49 | 50 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.helpers.alwaysdirty.svg)](http://www.npmjs.org/package/jquery.dirtyforms.helpers.alwaysdirty) 51 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.helpers.alwaysdirty.svg)](http://bower.io/search/?q=jquery.dirtyforms.helpers.alwaysdirty) 52 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.helpers.alwaysdirty.svg)](https://www.nuget.org/packages/jquery.dirtyforms.helpers.alwaysdirty/) 53 | 54 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.helpers.alwaysdirty.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.helpers.alwaysdirty/) 55 | ``` 56 | // NPM 57 | $ npm install jquery.dirtyforms.helpers.alwaysdirty 58 | 59 | // Bower 60 | $ bower install jquery.dirtyforms.helpers.alwaysdirty 61 | 62 | // NuGet 63 | PM> Install-Package jquery.dirtyforms.helpers.alwaysdirty 64 | ``` 65 | 66 | ## SourceMaps 67 | 68 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 69 | 70 | #### CDN 71 | 72 | ```HTML 73 | 74 | ``` 75 | 76 | #### Package Managers 77 | 78 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 79 | 80 | ``` 81 | jquery.dirtyforms.helpers.alwaysdirty.min.js.map 82 | ``` 83 | 84 | ## Usage 85 | 86 | This helper is completely automatic - there are no properties or methods to interact with. Simply include the reference to the helper after the [prerequisites](#prerequisites). 87 | 88 | ```HTML 89 | 90 | 91 | 92 | ``` 93 | 94 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 95 | 96 | 97 | ## Support 98 | 99 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). 100 | -------------------------------------------------------------------------------- /helpers/ckeditor.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.helpers.ckeditor 6 | 7 | This is a helper module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This helper causes Dirty Forms to read and/or update the dirty status from CKEditor instances on the form. This will ensure that when a user edits a CKEditor field, Dirty Forms will be notified of the event in order to mark the form dirty. 12 | 13 | ## Prerequisites 14 | 15 | Prerequesites must be included in this order: 16 | 17 | - [jQuery](http://jquery.com) (>= 1.4.2) 18 | - [CKEditor](http://ckeditor.com/download) 19 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 20 | 21 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 22 | 23 | ## Download & Installation 24 | There are several different ways to get the code. Some examples below: 25 | 26 | #### CDN 27 | The CKEditor helper is available over jsDelivr CDN and can directly be included on every page. 28 | ```HTML 29 | 30 | ``` 31 | 32 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, ckeditor, jquery.dirtyforms, and jquery.dirtyforms.helpers.ckeditor in one request. 33 | ```HTML 34 | 35 | ``` 36 | 37 | #### Self-Hosted 38 | Download and save one of two available files to include the CKEditor helper to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.ckeditor.dist/master/jquery.dirtyforms.helpers.ckeditor.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.ckeditor.dist/master/jquery.dirtyforms.helpers.ckeditor.min.js) version. 39 | ```HTML 40 | 41 | ``` 42 | 43 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 44 | 45 | #### Package Managers 46 | The CKEditor helper is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the helper, including all dependencies. 47 | 48 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.helpers.ckeditor.svg)](http://www.npmjs.org/package/jquery.dirtyforms.helpers.ckeditor) 49 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.helpers.ckeditor.svg)](http://bower.io/search/?q=jquery.dirtyforms.helpers.ckeditor) 50 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.helpers.ckeditor.svg)](https://www.nuget.org/packages/jquery.dirtyforms.helpers.ckeditor/) 51 | 52 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.helpers.ckeditor.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.helpers.ckeditor/) 53 | ``` 54 | // NPM 55 | $ npm install jquery.dirtyforms.helpers.ckeditor 56 | 57 | // Bower 58 | $ bower install jquery.dirtyforms.helpers.ckeditor 59 | 60 | // NuGet 61 | PM> Install-Package jquery.dirtyforms.helpers.ckeditor 62 | ``` 63 | 64 | ## SourceMaps 65 | 66 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 67 | 68 | #### CDN 69 | 70 | ```HTML 71 | 72 | ``` 73 | 74 | #### Package Managers 75 | 76 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 77 | 78 | ``` 79 | jquery.dirtyforms.helpers.ckeditor.min.js.map 80 | ``` 81 | 82 | ## Usage 83 | 84 | This helper is completely automatic - there are no properties or methods to interact with. Simply include the reference to the helper after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and CKEditor [as per the documetation](http://docs.ckeditor.com/#!/guide/dev_installation). 85 | 86 | ```HTML 87 | 88 | 89 | 90 | 91 | ``` 92 | 93 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 94 | 95 | 96 | ## Support 97 | 98 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). 99 | -------------------------------------------------------------------------------- /helpers/tinymce.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.helpers.tinymce 6 | 7 | This is a helper module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This helper causes Dirty Forms to read and/or update the dirty status from TinyMCE instances on the form. This will ensure that when a user edits a TinyMCE field, Dirty Forms will be notified of the event in order to mark the form dirty. 12 | 13 | ## Prerequisites 14 | 15 | Prerequesites must be included in this order: 16 | 17 | - [jQuery](http://jquery.com) (>= 1.4.2) 18 | - tinymce 19 | - jquery.tinymce 20 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 21 | 22 | Both of the TinyMCE files are included in the [TinyMCE jQuery package](http://www.tinymce.com/download/download.php). 23 | 24 | **Note:** There are [known compatibility issues](http://bugs.jquery.com/ticket/11527) between jQuery 1.7.2 and higher and TinyMCE versions lower than 3.5b3. These issues can cause the dialog proceed function to fail in dirtyForms. 25 | 26 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 27 | 28 | ## Download & Installation 29 | There are several different ways to get the code. Some examples below: 30 | 31 | #### CDN 32 | The TinyMCE helper is available over jsDelivr CDN and can directly be included on every page. 33 | ```HTML 34 | 35 | ``` 36 | 37 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, TinyMCE, the jQuery TinyMCE plugin, jquery.dirtyforms, and jquery.dirtyforms.helpers.tinymce in one request. 38 | ```HTML 39 | 40 | ``` 41 | 42 | #### Self-Hosted 43 | Download and save one of two available files to include the TinyMCE helper to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.tinymce.dist/master/jquery.dirtyforms.helpers.tinymce.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.helpers.tinymce.dist/master/jquery.dirtyforms.helpers.tinymce.min.js) version. 44 | ```HTML 45 | 46 | ``` 47 | 48 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 49 | 50 | #### Package Managers 51 | The TinyMCE helper is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the helper, including all dependencies. 52 | 53 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.helpers.tinymce.svg)](http://www.npmjs.org/package/jquery.dirtyforms.helpers.tinymce) 54 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.helpers.tinymce.svg)](http://bower.io/search/?q=jquery.dirtyforms.helpers.tinymce) 55 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.helpers.tinymce.svg)](https://www.nuget.org/packages/jquery.dirtyforms.helpers.tinymce/) 56 | 57 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.helpers.tinymce.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.helpers.tinymce/) 58 | ``` 59 | // NPM 60 | $ npm install jquery.dirtyforms.helpers.tinymce 61 | 62 | // Bower 63 | $ bower install jquery.dirtyforms.helpers.tinymce 64 | 65 | // NuGet 66 | PM> Install-Package jquery.dirtyforms.helpers.tinymce 67 | ``` 68 | 69 | ## SourceMaps 70 | 71 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 72 | 73 | #### CDN 74 | 75 | ```HTML 76 | 77 | ``` 78 | 79 | #### Package Managers 80 | 81 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 82 | 83 | ``` 84 | jquery.dirtyforms.helpers.tinymce.min.js.map 85 | ``` 86 | 87 | ## Usage 88 | 89 | This helper is completely automatic - there are no properties or methods to interact with. Simply include the reference to the helper after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and TinyMCE [as per the documentation](http://www.tinymce.com/wiki.php/Installation). 90 | 91 | ```HTML 92 | 93 | 94 | 95 | 96 | 97 | ``` 98 | 99 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 100 | 101 | 102 | ## Support 103 | 104 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). 105 | -------------------------------------------------------------------------------- /dialogs/bootstrap.js: -------------------------------------------------------------------------------- 1 | /*! 2 | Bootstrap modal dialog (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2015-2016 Shad Storhaug 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | var exclamationGlyphicon = ' '; 31 | 32 | $.DirtyForms.dialog = { 33 | // Custom properties and methods to allow overriding (may differ per dialog) 34 | title: exclamationGlyphicon + 'Are you sure you want to do that?', 35 | proceedButtonClass: 'dirty-proceed', 36 | proceedButtonText: 'Leave This Page', 37 | stayButtonClass: 'dirty-stay', 38 | stayButtonText: 'Stay Here', 39 | dialogID: 'dirty-dialog', 40 | titleID: 'dirty-title', 41 | messageClass: 'dirty-message', 42 | preMessageText: '', 43 | postMessageText: '', 44 | replaceText: true, 45 | 46 | // Typical Dirty Forms Properties and Methods 47 | open: function (choice, message) { 48 | // Look for a pre-existing element with the dialogID. 49 | var $dialog = $('#' + this.dialogID); 50 | 51 | // If the user already added a dialog with this ID, skip doing it here 52 | if ($dialog.length === 0) { 53 | // NOTE: Buttons don't have the ignore class because Bootstrap 3 isn't compatible 54 | // with old versions of jQuery that don't properly cancel the click events. 55 | $dialog = 56 | $(''); 71 | 72 | // Append to the body so we can capture DOM events. 73 | // Flag the dialog for later removal. 74 | $('body').append($dialog) 75 | .data('df-dialog-appended', true); 76 | } 77 | 78 | if (this.replaceText) { 79 | // Replace the text in the dialog (whether it is external or not). 80 | $dialog.find('#' + this.titleID).html(this.title); 81 | $dialog.find('.' + this.messageClass).html(this.preMessageText + message + this.postMessageText); 82 | $dialog.find('.' + this.proceedButtonClass).html(this.proceedButtonText); 83 | $dialog.find('.' + this.stayButtonClass).html(this.stayButtonText); 84 | } 85 | 86 | // Bind the events 87 | choice.bindEscKey = false; 88 | 89 | var onContinueClick = function () { 90 | choice.proceed = $.DirtyForms.choiceContinue = true; 91 | }; 92 | var onHidden = function (e) { 93 | var commit = choice.isDF1 ? $.DirtyForms.choiceCommit : choice.commit; 94 | commit(e); 95 | if ($('body').data('df-dialog-appended') === true) { 96 | $dialog.remove(); 97 | } 98 | }; 99 | // NOTE: Bootstrap 3 requires jQuery 1.9, so we can use on and off here. 100 | $dialog.find('.' + this.proceedButtonClass).off('click', onContinueClick).on('click', onContinueClick); 101 | $dialog.off('hidden.bs.modal', onHidden).on('hidden.bs.modal', onHidden); 102 | 103 | // Show the dialog 104 | $dialog.modal({ show: true }); 105 | }, 106 | 107 | // Support for Dirty Forms < 2.0 108 | fire: function (message, title) { 109 | this.title = exclamationGlyphicon + title; 110 | this.open({ isDF1: true }, message); 111 | }, 112 | 113 | // Support for Dirty Forms < 1.2 114 | bind: function () { 115 | }, 116 | stash: function () { 117 | return false; 118 | }, 119 | refire: function () { 120 | return false; 121 | }, 122 | selector: 'no-op', 123 | }; 124 | 125 | /**/ 126 | })); 127 | /**/ -------------------------------------------------------------------------------- /dialogs/facebox.js: -------------------------------------------------------------------------------- 1 | /*! 2 | Facebox dialog module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2015-2016 Shad Storhaug 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | $.DirtyForms.dialog = { 31 | // Custom properties and methods to allow overriding (may differ per dialog) 32 | title: 'Are you sure you want to do that?', 33 | proceedButtonClass: '', 34 | proceedButtonText: 'Leave This Page', 35 | stayButtonClass: '', 36 | stayButtonText: 'Stay Here', 37 | 38 | // Typical Dirty Forms Properties and Methods 39 | 40 | // Selector for stashing the content of another dialog. 41 | stashSelector: '#facebox .content', 42 | open: function (choice, message, ignoreClass) { 43 | var content = 44 | '

' + this.title + '

' + 45 | '

' + message + '

' + 46 | '

' + 47 | '' + this.proceedButtonText + '' + 48 | '' + this.stayButtonText + '' + 49 | '

'; 50 | $.facebox(content); 51 | 52 | // Bind Events 53 | choice.bindEnterKey = true; 54 | choice.staySelector = '#facebox .dirty-stay, #facebox .close, #facebox_overlay'; 55 | choice.proceedSelector = '#facebox .dirty-proceed'; 56 | 57 | if (choice.isDF1) { 58 | var close = function (decision) { 59 | return function (e) { 60 | if (e.type !== 'keydown' || (e.type === 'keydown' && (e.which == 27 || e.which == 13))) { 61 | // Facebox hack: If we call close when returning from the stash, the 62 | // stash dialog will close, so we guard against calling close in that case. 63 | if (!$.DirtyForms.dialogStash) { 64 | $(document).trigger('close.facebox'); 65 | } 66 | decision(e); 67 | } 68 | }; 69 | }; 70 | var decidingCancel = $.DirtyForms.decidingCancel; 71 | $(document).bind('keydown.facebox', close(decidingCancel)); 72 | $(choice.staySelector).click(close(decidingCancel)); 73 | $(choice.proceedSelector).click(close($.DirtyForms.decidingContinue)); 74 | } 75 | }, 76 | close: function (continuing, unstashing) { 77 | // Facebox hack: If we call close when returning from the stash, the 78 | // stash dialog will close, so we guard against calling close in that case. 79 | if (!unstashing) { 80 | $(document).trigger('close.facebox'); 81 | } 82 | }, 83 | stash: function () { 84 | var isDF1 = typeof $.DirtyForms.isDeciding === 'function', 85 | $fb = $('#facebox'), 86 | $content = $fb.find('.content'); 87 | 88 | // Store the DOM state as actual HTML DOM values 89 | $content.find('datalist,select,textarea,input').not('[type="button"],[type="submit"],[type="reset"],[type="image"]').each(function () { 90 | storeFieldValue($(this)); 91 | }); 92 | 93 | return ($.trim($fb.html()) === '' || $fb.css('display') != 'block') ? 94 | false : 95 | isDF1 ? 96 | $content.clone(true) : 97 | $content.children().clone(true); 98 | }, 99 | unstash: function (stash, ev) { 100 | $.facebox(stash); 101 | }, 102 | 103 | // Support for Dirty Forms < 2.0 104 | fire: function (message, title) { 105 | this.title = title; 106 | this.open({ isDF1: true }, message, $.DirtyForms.ignoreClass); 107 | }, 108 | selector: $.DirtyForms.dialog.stashSelector, 109 | 110 | // Support for Dirty Forms < 1.2 111 | bind: function () { 112 | }, 113 | refire: function (content, ev) { 114 | this.unstash(content, ev); 115 | } 116 | }; 117 | 118 | var storeFieldValue = function ($field) { 119 | if ($field.is('select,datalist')) { 120 | $field.find('option').each(function () { 121 | var $option = $(this); 122 | if ($option.is(':selected')) { 123 | $option.attr('selected', 'selected'); 124 | } else { 125 | $option.removeAttr('selected'); 126 | } 127 | }); 128 | } else if ($field.is(":checkbox,:radio")) { 129 | if ($field.is(':checked')) { 130 | $field.attr('checked', 'checked'); 131 | } else { 132 | $field.removeAttr('checked'); 133 | } 134 | } else if ($field.is('textarea')) { 135 | $field.text($field.val()); 136 | } else { 137 | $field.attr('value', $field.val()); 138 | } 139 | }; 140 | 141 | /**/ 142 | })); 143 | /**/ 144 | -------------------------------------------------------------------------------- /dialogs/pnotify.js: -------------------------------------------------------------------------------- 1 | /*! 2 | PNotify dialog module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2015-2016 Shad Storhaug 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | var modal_overlay, 31 | notice, 32 | isPN1 = typeof PNotify !== 'function'; 33 | 34 | $.DirtyForms.dialog = { 35 | 36 | // Custom properties and methods to allow overriding (may differ per dialog) 37 | title: 'Are you sure you want to do that?', 38 | class: 'dirty-dialog', 39 | proceedButtonText: 'Leave This Page', 40 | stayButtonText: 'Stay Here', 41 | styling: 'bootstrap3', 42 | width: '330', 43 | 44 | // Typical Dirty Forms Properties and Methods 45 | open: function (choice, message, ignoreClass) { 46 | var content = $.extend(true, {}, { 47 | title: this.title, 48 | hide: false, 49 | styling: this.styling, 50 | width: this.width, 51 | 52 | // 3.x and 2.x confirm buttons 53 | confirm: { 54 | confirm: true, 55 | align: 'center', 56 | buttons: [ 57 | { 58 | text: this.proceedButtonText, 59 | addClass: 'dirty-proceed ' + ignoreClass 60 | }, 61 | { 62 | text: this.stayButtonText, 63 | addClass: 'dirty-stay ' + ignoreClass 64 | } 65 | ] 66 | }, 67 | // 3.x don't use history 68 | history: { 69 | history: false 70 | }, 71 | // 3.x modal dialog 72 | addclass: 'stack-modal ' + this.class, 73 | stack: { 'dir1': 'down', 'dir2': 'right', 'modal': true }, 74 | 75 | // 3.x and 2.x hide closer and sticker 76 | buttons: { 77 | closer: false, 78 | sticker: false 79 | }, 80 | // 1.x hide closer and sticker 81 | closer: false, 82 | sticker: false, 83 | 84 | // NOTE: Animate does not seem to work in 3.x in conjunction with confirm, 85 | // but this is being added so the settings can be supplied externally should 86 | // this issue be fixed. https://github.com/sciactive/pnotify/issues/224 87 | animate: this.animate === undefined ? undefined : this.animate, 88 | 89 | text: !isPN1 ? message : 90 | '' + 91 | '

' + message + '

' + 92 | '' + 93 | ' ' + 94 | '' + 95 | '' + 96 | '
', 97 | 98 | // Not supported in 3.x 99 | before_open: function (PNotify) { 100 | if (!isPN1) { 101 | // Position this notice in the center of the screen. 102 | PNotify.get().css({ 103 | "top": ($(window).height() / 2) - (PNotify.get().height() / 2), 104 | "left": ($(window).width() / 2) - (PNotify.get().width() / 2) 105 | }); 106 | } 107 | 108 | // Make a modal screen overlay. 109 | if (modal_overlay) modal_overlay.fadeIn("fast"); 110 | else modal_overlay = $("
", { 111 | "class": "ui-widget-overlay", 112 | "css": { 113 | "display": "none", 114 | "position": "fixed", 115 | "top": "0", 116 | "bottom": "0", 117 | "right": "0", 118 | "left": "0" 119 | } 120 | }).appendTo("body").fadeIn("fast"); 121 | } 122 | }); 123 | 124 | // Patch for PNotify 1.x 125 | notice = !isPN1 ? new PNotify(content) : $.pnotify(content); 126 | 127 | // Bind Events 128 | choice.bindEnterKey = true; 129 | choice.proceedSelector = '.' + this.class + ' .dirty-proceed'; 130 | choice.staySelector = '.' + this.class + ' .dirty-stay,.ui-widget-overlay'; 131 | 132 | // Support for Dirty Forms < 2.0 133 | if (choice.isDF1) { 134 | var close = function (decision) { 135 | return function (e) { 136 | if (e.type !== 'keydown' || (e.type === 'keydown' && (e.which == 27 || e.which == 13))) { 137 | notice.remove(); 138 | if (modal_overlay) modal_overlay.fadeOut("fast"); 139 | decision(e); 140 | return false; 141 | } 142 | }; 143 | }; 144 | // Trap the escape key and force a close. Cancel it so PNotify doesn't intercept it. 145 | var decidingCancel = $.DirtyForms.decidingCancel; 146 | $(document).keydown(close(decidingCancel)); 147 | $(choice.staySelector).click(close(decidingCancel)); 148 | $(choice.proceedSelector).click(close($.DirtyForms.decidingContinue)); 149 | } 150 | }, 151 | close: function () { 152 | notice.remove(); 153 | if (modal_overlay) modal_overlay.fadeOut("fast"); 154 | }, 155 | 156 | // Support for Dirty Forms < 2.0 157 | fire: function (message, title) { 158 | this.title = title; 159 | this.open({ isDF1: true }, message, $.DirtyForms.ignoreClass); 160 | }, 161 | 162 | // Support for Dirty Forms < 1.2 163 | bind: function () { 164 | }, 165 | stash: function () { 166 | return false; 167 | }, 168 | refire: function () { 169 | return false; 170 | }, 171 | selector: 'no-op' 172 | }; 173 | 174 | /**/ 175 | })); 176 | /**/ -------------------------------------------------------------------------------- /dialogs/jquery-ui.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.dialogs.jquery-ui 6 | 7 | This is a dialog module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This module causes Dirty Forms to use jQuery UI as its dialog when the user attempts to leave the page by clicking a hyperlink (but not when interacting with the navigation buttons of the browser). 12 | 13 | > Only 1 dialog module can be used by Dirty Forms at a time. The default behavior without this package is to use the browser's built in dialog that is fired by the `beforeunload` event. 14 | 15 | ## Prerequisites 16 | 17 | Prerequesites must be included in this order: 18 | 19 | - [jQuery](http://jquery.com) (>= 1.4.2) 20 | - [jquery-ui](http://jqueryui.com/download/) (>= 1.8.14) - both the JS for the jQuery UI dialog (or a combined package) and CSS 21 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 22 | 23 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 24 | 25 | ## Download & Installation 26 | There are several different ways to get the code. Some examples below: 27 | 28 | #### CDN 29 | The jQuery UI dialog module is available over jsDelivr CDN and can directly be included on every page. 30 | ```HTML 31 | 32 | ``` 33 | 34 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, jQuery UI, jquery.dirtyforms, and jquery.dirtyforms.dialogs.jquery-ui in one request. 35 | ```HTML 36 | 37 | ``` 38 | 39 | #### Self-Hosted 40 | Download and save one of two available files to include the jQuery UI dialog module to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.jquery-ui.dist/master/jquery.dirtyforms.dialogs.jquery-ui.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.jquery-ui.dist/master/jquery.dirtyforms.dialogs.jquery-ui.min.js) version. 41 | ```HTML 42 | 43 | ``` 44 | 45 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 46 | 47 | #### Package Managers 48 | The jQuery UI dialog module is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the dialog module, including all dependencies. 49 | 50 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.dialogs.jquery-ui.svg)](http://www.npmjs.org/package/jquery.dirtyforms.dialogs.jquery-ui) 51 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.dialogs.jquery-ui.svg)](http://bower.io/search/?q=jquery.dirtyforms.dialogs.jquery-ui) 52 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.dialogs.jquery-ui.svg)](https://www.nuget.org/packages/jquery.dirtyforms.dialogs.jquery-ui/) 53 | 54 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.dialogs.jquery-ui.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.dialogs.jquery-ui/) 55 | ``` 56 | // NPM 57 | $ npm install jquery.dirtyforms.dialogs.jquery-ui 58 | 59 | // Bower 60 | $ bower install jquery.dirtyforms.dialogs.jquery-ui 61 | 62 | // NuGet 63 | PM> Install-Package jquery.dirtyforms.dialogs.jquery-ui 64 | ``` 65 | 66 | ## SourceMaps 67 | 68 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 69 | 70 | #### CDN 71 | 72 | ```HTML 73 | 74 | ``` 75 | 76 | #### Package Managers 77 | 78 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 79 | 80 | ``` 81 | jquery.dirtyforms.dialogs.jquery-ui.min.js.map 82 | ``` 83 | 84 | ## Usage 85 | 86 | This dialog module is automatic. Simply include the reference to the dialog module after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and jQuery UI [as per the documentation](https://api.jqueryui.com/dialog/). 87 | 88 | ```HTML 89 | // CSS 90 | // jQuery UI (many other themes available at [jsDelivr](https://github.com/jsdelivr/jsdelivr/tree/master/files/jquery.ui/1.11.3/themes)) 91 | 92 | 93 | // JavaScript 94 | 95 | 96 | 97 | 98 | ``` 99 | 100 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 101 | 102 | ## Options 103 | 104 | The following options are available to set via **$.DirtyForms.dialog.OPTIONNAME = OPTIONVALUE** or get via **OPTIONVALUE = $.DirtyForms.dialog.OPTIONNAME** 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
NameTypeDefaultDescription
titlestring'Are you sure you want to do that?'Sets the title of the dialog.
proceedButtonTextstring'Leave This Page'Sets the text of the continue button of the dialog.
stayButtonTextstring'Stay Here'Sets the text of the cancel button of the dialog.
preMessageTextstring''Sets the text that precedes the message text. May contain HTML.
postMessageTextstring''Sets the text that follows the message text. May contain HTML.
widthint430The width of the dialog.
150 | 151 | 152 | ## Support 153 | 154 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). 155 | -------------------------------------------------------------------------------- /helpers/tinymce.js: -------------------------------------------------------------------------------- 1 | /*! 2 | TinyMCE helper module (for jQuery Dirty Forms) | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2013-2016 Mal Curtis 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | var tinymceSelector = ':tinymce:not(.dirty-forms-temp)', 31 | ignoreSelector = '.mceEditor a,.mceMenu a,[name^="mce_"]'; 32 | 33 | // Create a new object, with an isDirty method 34 | var tinymce = { 35 | // Dirty Forms properties and methods 36 | ignoreSelector: ignoreSelector, 37 | isDirty: function ($node) { 38 | var isDirty = false; 39 | if (hasTinyMCE($node)) { 40 | // Search the current node and all descendant nodes that match the selector 41 | $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () { 42 | var $field = $(this); 43 | 44 | $.DirtyForms.dirtylog('Checking node ' + $field.attr('id')); 45 | if (typeof $field.data('df-tinymce-orig') === 'undefined') { 46 | // For Dirty Forms < 2.0 and TinyMCE elements that were added via AJAX, 47 | // we default to using TinyMCE's isDirty behavior (which is stateless). 48 | if ($field.tinymce().isDirty()) { 49 | isDirty = true; 50 | $.DirtyForms.dirtylog('Node was totally dirty.'); 51 | // Return false to stop iterating. 52 | return false; 53 | } 54 | } else { 55 | // For Dirty Forms >= 2.0, we compare hash codes with the original content 56 | var content = getTinyMceContent($field); 57 | $.DirtyForms.dirtylog('TinyMCE content: ' + content); 58 | var hash = getHashCode(content); 59 | $.DirtyForms.dirtylog('TinyMCE hash: ' + hash); 60 | var originalHash = $field.data('df-tinymce-orig'); 61 | $.DirtyForms.dirtylog('Original TinyMCE hash: ' + originalHash); 62 | 63 | if (hash !== originalHash) { 64 | isDirty = true; 65 | $.DirtyForms.dirtylog('Node was totally dirty.'); 66 | // Return false to stop iterating. 67 | return false; 68 | } 69 | } 70 | }); 71 | } 72 | return isDirty; 73 | }, 74 | setClean: function ($node) { 75 | if (hasTinyMCE($node)) { 76 | 77 | // Search the current node and all descendant nodes that match the selector 78 | $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () { 79 | var $field = $(this); 80 | 81 | // Set TinyMCE clean 82 | if ($field.tinymce().isDirty()) { 83 | $.DirtyForms.dirtylog('Resetting isDirty on node ' + $field.attr('id')); 84 | $field.tinymce().isNotDirty = 1; //Force not dirty state 85 | } 86 | 87 | // Forget the original value and reset to the current state 88 | storeOriginalValue($field); 89 | }); 90 | } 91 | }, 92 | rescan: function ($node) { 93 | if (hasTinyMCE($node)) { 94 | $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () { 95 | var $field = $(this); 96 | 97 | if (typeof $field.data('df-tinymce-orig') !== 'undefined') { 98 | storeOriginalValue($field); 99 | } 100 | }); 101 | } 102 | }, 103 | 104 | // Patch for Dirty Forms < 2.0 105 | ignoreAnchorSelector: ignoreSelector 106 | }; 107 | 108 | // Push the new object onto the helpers array 109 | $.DirtyForms.helpers.push(tinymce); 110 | 111 | // Fix: tinymce throws an error if the selector doesn't match anything 112 | // (such as when there are no textareas on the current page) 113 | var hasTinyMCE = function ($node) { 114 | try { 115 | return $node.filter(tinymceSelector).length > 0 || $node.find(tinymceSelector).length > 0; 116 | } 117 | catch (e) { 118 | return false; 119 | } 120 | }; 121 | 122 | var getTinyMceContent = function ($field) { 123 | // Hack: TinyMCE puts an extra
tag at the end of a paragraph when it is edited, so ignore that case. 124 | return $field.tinymce().getContent({ format: 'raw' }).replace(/
<\/p>/mg, '

'); 125 | }; 126 | 127 | var storeOriginalValue = function ($field) { 128 | var content = getTinyMceContent($field); 129 | $.DirtyForms.dirtylog('Original TinyMCE content: ' + content); 130 | 131 | var hash = getHashCode(content); 132 | $.DirtyForms.dirtylog('Original TinyMCE hash: ' + hash); 133 | 134 | $field.data('df-tinymce-orig', hash); 135 | }; 136 | 137 | // When TinyMCE is found, store the original value as a hash so we can see if there are changes later. 138 | var init = function ($node) { 139 | if (hasTinyMCE($node)) { 140 | $node.filter(tinymceSelector).add($node.find(tinymceSelector)).each(function () { 141 | storeOriginalValue($(this)); 142 | }); 143 | } 144 | }; 145 | 146 | $(document).bind('scan.dirtyforms', function (ev) { 147 | // Hack: TinyMCE doesn't have a global init event. So, we create a new 148 | // TinyMCE editor within an invisible div and respond to its init event. 149 | // There doesn't seem to be a reasonable way 150 | // to remove the control again, so we simply ignore it. 151 | var $form = $(ev.target); 152 | var $editor = $(''); 153 | $form.append($editor); 154 | $editor.tinymce({ 155 | oninit: function () { 156 | init($form); 157 | } 158 | }); 159 | }); 160 | 161 | // Simple way to hash a string: http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery 162 | var getHashCode = function (str) { 163 | var hash = 0, i, chr, len; 164 | if (str.length === 0) return hash; 165 | for (i = 0, len = str.length; i < len; i++) { 166 | chr = str.charCodeAt(i); 167 | hash = ((hash << 5) - hash) + chr; 168 | hash |= 0; // Convert to 32bit integer 169 | } 170 | return hash; 171 | }; 172 | 173 | /**/ 174 | })); 175 | /**/ -------------------------------------------------------------------------------- /dialogs/facebox.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.dialogs.facebox 6 | 7 | This is a dialog module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This module causes Dirty Forms to use Facebox as its dialog when the user attempts to leave the page by clicking a hyperlink (but not when interacting with the navigation buttons of the browser). 12 | 13 | > Only 1 dialog module can be used by Dirty Forms at a time. The default behavior without this package is to use the browser's built in dialog that is fired by the `beforeunload` event. 14 | 15 | ## Prerequisites 16 | 17 | Prerequesites must be included in this order: 18 | 19 | - [jQuery](http://jquery.com) (>= 1.4.2) - Stashing support for select elements requires jQuery >= 1.6 20 | - [jquery.facebox](https://github.com/NightOwl888/facebox) (>= 1.4.1) - both the CSS and JS 21 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 22 | 23 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 24 | 25 | ## Download & Installation 26 | There are several different ways to get the code. Some examples below: 27 | 28 | #### CDN 29 | The Facebox dialog module is available over jsDelivr CDN and can directly be included on every page. 30 | ```HTML 31 | 32 | ``` 33 | 34 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, jquery.facebox, jquery.dirtyforms, and jquery.dirtyforms.dialogs.facebox in one request. 35 | ```HTML 36 | 37 | ``` 38 | 39 | #### Self-Hosted 40 | Download and save one of two available files to include the Facebox dialog module to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.facebox.dist/master/jquery.dirtyforms.dialogs.facebox.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.facebox.dist/master/jquery.dirtyforms.dialogs.facebox.min.js) version. 41 | ```HTML 42 | 43 | ``` 44 | 45 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 46 | 47 | #### Package Managers 48 | The Facebox dialog module is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the dialog module, including all dependencies. 49 | 50 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.dialogs.facebox.svg)](http://www.npmjs.org/package/jquery.dirtyforms.dialogs.facebox) 51 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.dialogs.facebox.svg)](http://bower.io/search/?q=jquery.dirtyforms.dialogs.facebox) 52 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.dialogs.facebox.svg)](https://www.nuget.org/packages/jquery.dirtyforms.dialogs.facebox/) 53 | 54 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.dialogs.facebox.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.dialogs.facebox/) 55 | ``` 56 | // NPM 57 | $ npm install jquery.dirtyforms.dialogs.facebox 58 | 59 | // Bower 60 | $ bower install jquery.dirtyforms.dialogs.facebox 61 | 62 | // NuGet 63 | PM> Install-Package jquery.dirtyforms.dialogs.facebox 64 | ``` 65 | 66 | ## SourceMaps 67 | 68 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 69 | 70 | #### CDN 71 | 72 | ```HTML 73 | 74 | ``` 75 | 76 | #### Package Managers 77 | 78 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 79 | 80 | ``` 81 | jquery.dirtyforms.dialogs.facebox.min.js.map 82 | ``` 83 | 84 | ## Usage 85 | 86 | This dialog module is automatic. Simply include the reference to the dialog module after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and Facebox [as per the documentation](http://github.com/NightOwl888/jquery.facebox). 87 | 88 | ```HTML 89 | // CSS 90 | 91 | 92 | // JavaScript 93 | 94 | 95 | 96 | 97 | ``` 98 | 99 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 100 | 101 | ## Options 102 | 103 | The following options are available to set via **$.DirtyForms.dialog.OPTIONNAME = OPTIONVALUE** or get via **OPTIONVALUE = $.DirtyForms.dialog.OPTIONNAME** 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |
NameTypeDefaultDescription
titlestring'Are you sure you want to do that?'Sets the title of the dialog.
proceedButtonClassstring''Sets the CSS class of the continue button of the dialog (an HTML anchor tag element).
proceedButtonTextstring'Leave This Page'Sets the text of the continue button of the dialog.
stayButtonClassstring''Sets the CSS class of the cancel button of the dialog (an HTML anchor tag element).
stayButtonTextstring'Stay Here'Sets the text of the cancel button of the dialog.
stashSelectorstring'#facebox .content'When using stashing, setting this selector chooses the element of the modal dialog containing your form that will be included in the stash and later restored during unstash (if the user clicks cancel).
149 | 150 | > For information about stashing, see the [Modal Dialog Stashing](https://github.com/snikch/jquery.dirtyforms#modal-dialog-stashing) section. 151 | 152 | 153 | ## Support 154 | 155 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). 156 | -------------------------------------------------------------------------------- /dialogs/blockui.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.dialogs.blockui 6 | 7 | This is a dialog module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This module causes Dirty Forms to use BlockUI as its dialog when the user attempts to leave the page by clicking a hyperlink (but not when interacting with the navigation buttons of the browser). 12 | 13 | > Only 1 dialog module can be used by Dirty Forms at a time. The default behavior without this package is to use the browser's built in dialog that is fired by the `beforeunload` event. 14 | 15 | ## Prerequisites 16 | 17 | Prerequesites must be included in this order: 18 | 19 | - [jQuery](http://jquery.com) (>= 1.7) 20 | - [BlockUI](http://malsup.com/jquery/block/) (>= 2.70) 21 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 22 | 23 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 24 | 25 | ## Download & Installation 26 | There are several different ways to get the code. Some examples below: 27 | 28 | #### CDN 29 | The BlockUI dialog module is available over jsDelivr CDN and can directly be included on every page. 30 | ```HTML 31 | 32 | ``` 33 | 34 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, BlockUI, jquery.dirtyforms, and jquery.dirtyforms.dialogs.blockui in one request. 35 | ```HTML 36 | 37 | ``` 38 | 39 | #### Self-Hosted 40 | Download and save one of two available files to include the BlockUI dialog module to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.blockui.dist/master/jquery.dirtyforms.dialogs.blockui.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.blockui.dist/master/jquery.dirtyforms.dialogs.blockui.min.js) version. 41 | ```HTML 42 | 43 | ``` 44 | 45 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 46 | 47 | #### Package Managers 48 | The BlockUI dialog module is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the dialog module, including all dependencies. 49 | 50 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.dialogs.blockui.svg)](http://www.npmjs.org/package/jquery.dirtyforms.dialogs.blockui) 51 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.dialogs.blockui.svg)](http://bower.io/search/?q=jquery.dirtyforms.dialogs.blockui) 52 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.dialogs.blockui.svg)](https://www.nuget.org/packages/jquery.dirtyforms.dialogs.blockui/) 53 | 54 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.dialogs.blockui.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.dialogs.blockui/) 55 | ``` 56 | // NPM 57 | $ npm install jquery.dirtyforms.dialogs.blockui 58 | 59 | // Bower 60 | $ bower install jquery.dirtyforms.dialogs.blockui 61 | 62 | // NuGet 63 | PM> Install-Package jquery.dirtyforms.dialogs.blockui 64 | ``` 65 | 66 | ## SourceMaps 67 | 68 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 69 | 70 | #### CDN 71 | 72 | ```HTML 73 | 74 | ``` 75 | 76 | #### Package Managers 77 | 78 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 79 | 80 | ``` 81 | jquery.dirtyforms.dialogs.blockui.min.js.map 82 | ``` 83 | 84 | ## Usage 85 | 86 | This dialog module is automatic. Simply include the reference to the dialog module after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and BlockUI [as per the documentation](http://malsup.com/jquery/block/). 87 | 88 | ```HTML 89 | 90 | 91 | 92 | 93 | ``` 94 | 95 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 96 | 97 | ## Options 98 | 99 | The following options are available to set via **$.DirtyForms.dialog.OPTIONNAME = OPTIONVALUE** or get via **OPTIONVALUE = $.DirtyForms.dialog.OPTIONNAME** 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
NameTypeDefaultDescription
titlestring'Are you sure you want to do that?'Sets the title of the dialog.
classstring'dirty-dialog'Sets the CSS class of the SPAN element that contains all of the elements of the dialog.
proceedButtonTextstring'Leave This Page'Sets the text of the continue button of the dialog.
stayButtonTextstring'Stay Here'Sets the text of the cancel button of the dialog.
widthstring'400px'Sets the width of the dialog (passes the value to the css.width property of BlockUI).
paddingstring'10px'Sets the padding of the dialog (passes the value to the css.padding property of BlockUI).
colorstring'#000'Sets the foreground color of the dialog (passes the value to the css.color property of BlockUI).
borderstring'3px solid #aaa'Sets the border of the dialog (passes the value to the css.border property of BlockUI).
backgroundColorstring'#fff'Sets the background color of the dialog (passes the value to the css.backgroundColor property of BlockUI).
overlayOpacityfloat0.5Sets the opacity of the dialog overlay (passes the value to the overlayCSS.opacity property of BlockUI).
169 | 170 | 171 | ## Support 172 | 173 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). -------------------------------------------------------------------------------- /dialogs/pnotify.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.dialogs.pnotify 6 | 7 | This is a dialog module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This module causes Dirty Forms to use PNotify as its dialog when the user attempts to leave the page by clicking a hyperlink (but not when interacting with the navigation buttons of the browser). 12 | 13 | > Only 1 dialog module can be used by Dirty Forms at a time. The default behavior without this package is to use the browser's built in dialog that is fired by the `beforeunload` event. 14 | 15 | ## Prerequisites 16 | 17 | Prerequesites must be included in this order: 18 | 19 | - CSS theme from [BootStrap 3](http://getbootstrap.com/), [jQuery UI](http://jqueryui.com/themeroller/), or [Font Awesome](http://fontawesome.io/) 20 | - [jQuery](http://jquery.com) (>= 1.6.0) 21 | - [PNotify](http://sciactive.com/pnotify/) (>= 1.3) - both the CSS and JS 22 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 23 | 24 | **NOTE:** In PNotify 3.x, you must include the Confirm module and the History module JavaScript files after the main PNotify file. 25 | 26 | > If you are using a [Package Manager](#package-managers), the JavaScript dependencies will be installed automatically, but you will need to manually get a CSS theme if you are not already using one. Also, depending on your environment you may still need to add references to the JavaScript manually. 27 | 28 | ## Download & Installation 29 | There are several different ways to get the code. Some examples below: 30 | 31 | #### CDN 32 | The PNotify dialog module is available over jsDelivr CDN and can directly be included on every page. 33 | ```HTML 34 | 35 | ``` 36 | 37 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, PNotify, jquery.dirtyforms, and jquery.dirtyforms.dialogs.pnotify in one request. 38 | ```HTML 39 | 40 | ``` 41 | 42 | #### Self-Hosted 43 | Download and save one of two available files to include the PNotify dialog module to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.pnotify.dist/master/jquery.dirtyforms.dialogs.pnotify.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.pnotify.dist/master/jquery.dirtyforms.dialogs.pnotify.min.js) version. 44 | ```HTML 45 | 46 | ``` 47 | 48 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 49 | 50 | #### Package Managers 51 | The PNotify dialog module is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the dialog module, including all dependencies. 52 | 53 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.dialogs.pnotify.svg)](http://www.npmjs.org/package/jquery.dirtyforms.dialogs.pnotify) 54 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.dialogs.pnotify.svg)](http://bower.io/search/?q=jquery.dirtyforms.dialogs.pnotify) 55 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.dialogs.pnotify.svg)](https://www.nuget.org/packages/jquery.dirtyforms.dialogs.pnotify/) 56 | 57 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.dialogs.pnotify.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.dialogs.pnotify/) 58 | 59 | ``` 60 | // NPM 61 | $ npm install jquery.dirtyforms.dialogs.pnotify 62 | 63 | // Bower 64 | $ bower install jquery.dirtyforms.dialogs.pnotify 65 | 66 | // NuGet 67 | PM> Install-Package jquery.dirtyforms.dialogs.pnotify 68 | ``` 69 | 70 | ## SourceMaps 71 | 72 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 73 | 74 | #### CDN 75 | 76 | ```HTML 77 | 78 | ``` 79 | 80 | #### Package Managers 81 | 82 | Bower and NuGet will install the SourceMap file into the destination directory. 83 | 84 | ``` 85 | jquery.dirtyforms.dialogs.pnotify.min.js.map 86 | ``` 87 | 88 | ## Usage 89 | 90 | This dialog module is automatic. Simply include the reference to the dialog module after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and PNotify [as per the documentation](http://sciactive.com/pnotify/). 91 | 92 | ```HTML 93 | // Theme (use one of: BootStrap 3, jQuery UI, or Font Awesome) 94 | 95 | // BootStrap 3 96 | 97 | 98 | // jQuery UI (many other themes available at [jsDelivr](https://github.com/jsdelivr/jsdelivr/tree/master/files/jquery.ui/1.11.3/themes)) 99 | 100 | 101 | // Font Awesome 102 | 103 | 104 | // PNotify (required) 105 | 106 | 107 | // JavaScript (required) 108 | 109 | 110 | 111 | 112 | 113 | 114 | ``` 115 | 116 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 117 | 118 | ## Options 119 | 120 | The following options are available to set via **$.DirtyForms.dialog.OPTIONNAME = OPTIONVALUE** or get via **OPTIONVALUE = $.DirtyForms.dialog.OPTIONNAME** 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 |
NameTypeDefaultDescription
titlestring'Are you sure you want to do that?'Sets the title of the dialog.
classstring'dirty-dialog'Sets the CSS class of the DIV element (SPAN if using PNotify 1.3) that contains all of the elements of the dialog.
proceedButtonTextstring'Leave This Page'Sets the text of the continue button of the dialog.
stayButtonTextstring'Stay Here'Sets the text of the cancel button of the dialog.
stylingstring'bootstrap3'Sets the CSS theme you want to style PNotify. Available choices: 'bootstrap3', 'jqueryui', or 'fontawesome'. See the theme section of the PNotify documentation for details.
widthstring'330'Sets the width of the dialog.
-------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 2 | 3 | # Contributing to Dirty Forms 4 | 5 | Your contributions to the Dirty Forms project are welcome. While we have put a lot of time and thought into this project, we recognize that it can always be improved or extended in some way, and we appreciate the feedback. Contributions can take many forms. Here are some common ones. 6 | 7 | 1. [Opening an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) to let us know about something that appears to be defective or to give us an idea for a new feature 8 | 2. Contributing bug fixes for features you find that are defective 9 | 3. Contributing new features 10 | 4. Adding new helper or dialog modules 11 | 5. Helping to update the documentation if it is incorrect, incomplete, or out-of-date 12 | 6. Contributing unit tests/demos for existing features 13 | 7. Contributing additional distribution methods 14 | 15 | ### Issues 16 | 17 | Please provide as much detail as possible when submitting an issue. 18 | 19 | If we cannot reproduce your issue, there is little chance that it will be fixed or that we will be able to provide you with a working solution. Preference will be given to issues that provide demo projects (either by posting them on GitHub or zipping them and posting them for download). 20 | 21 | ### Code Contributions 22 | 23 | First of all, please read [Don't "Push" Your Pull Requests](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/). If you are thinking of making a change that will probably result in more than 5 changed lines of code, we would appreciate you [opening an issue](https://github.com/maartenba/MvcSiteMapProvider/issues/new) to discuss the change before you start writing. It could save both you and our team quite a bit of work if the code doesn't have to be rewritten to fit in with our overall objectives. Also, please review [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html). 24 | 25 | In general, we like features that provide value to a large subset of users that are closely related to form validation. 26 | 27 | ### Document Your Code 28 | 29 | We are following [semantic versioning](http://semver.org/). By definition, API members that are not documented are not taken into consideration when building for backward compatibility. Undocumented members may be removed from our codebase at any time for any reason. If you want your feature to be a permanent part of Dirty Forms, you must provide documentation for every public member that it exposes (either in the main readme or for the corresponding [helper or dialog](#helpersdialogs) readme). Besides, there is little point in contributing your "super feature" to our codebase if others cannot take advantage of it. 30 | 31 | ### Coding Conventions 32 | 33 | While we don't follow draconian coding practices, we ask that you do your best to follow existing conventions so the code is as consistent as possible. The code should be easy to read and understand, and should be broken into small, maintainable members that have a single purpose. Preferably, a single property or method will have no more than about 10 lines of code (including curly braces). 34 | 35 | Please create small focused commits that each deal with a single change. If the commit is to fix an issue, please prefix the commit message with (`fixes #` or `closes #`) to automatically close the issue that is fixed. For example, if you are submitting a fix to issue `#5`, the commit message should start with `fixes #5, ` and be followed by a short accurate description of the problem that was fixed. 36 | 37 | Please follow existing formatting practices. If your IDE will reformat the code in a major way, we suggest using a basic text editor to ensure only the code that you change is affected. Use common sense. If you want to add an event to monitor something that is happening in Dirty Forms, use the pre-existing event system (using jQuery trigger) rather than inventing your own brew. 38 | 39 | Please test your code. Dirty Forms tends to use features that sometimes break in certain browsers. So you should test in as many browsers as you can (especially Chrome, FireFox, Internet Explorer, and Safari). You can also run some basic JavaScript linting (using JSHint) with the following commands, which will help steer you away from some common coding pitfalls. 40 | 41 | ``` 42 | npm install 43 | npm test 44 | ``` 45 | 46 | ### Helpers/Dialogs 47 | 48 | Please follow these rules if you wish to contribute a helper or dialog module. 49 | 50 | #### Use UMD Header 51 | 52 | The Universal Module Definition allows others to compose plugins together by passing references (such as jQuery) to the module. We have adapted the [jqueryPluginCommonjs format](https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js), and request that you add it to your module before you submit it. If you have any doubts about how to use this on a jQuery plugin, take a look at the existing plugins. 53 | 54 | For more information about UMD, and why it is important see the following documents. 55 | 56 | - [UMD Project Readme](https://github.com/umdjs/umd#readme) 57 | - [Making your jQuery plugin work better with npm tools](http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm) 58 | 59 | #### Follow Existing Directory Structure 60 | 61 | We have built a script to package up the modules and deploy them in a consistent way. So it is important that you follow the same directory structure for new helpers and dialogs. The below examples assume you are contributing a new helper or module called `widget`. Replace widget in each of the paths with the name of your helper. 62 | 63 | Versioning of all helpers and dialogs will automatically be synced with Dirty Forms. Your package will automatically be deployed on jsDelivr when we do a distribution, so be sure to include it in the readme. Note that the CDN URLs in the `README.md` files will be automatically updated to the current version upon release. 64 | 65 | It is best to copy an existing helper or dialog and then use it as a starting point. 66 | 67 | ##### Helpers 68 | 69 | | Directory | Description | 70 | | ------------- | ------------- | 71 | | `/helpers/widget.js` | Helper code file (required) (must be a jQuery plugin and follow the UMD) | 72 | | `/helpers/widget.pkg/README.md` | Readme for your helper (required). Please provide a description, complete instructions on how to obtain and use the helper, its prerequisites, and how to install/reference via CDN. Note that if you use package managers, you can provide dependency information and the prerequisites can be installed automatically, so the documentation will be simpler. | 73 | | `/helpers/widget.pkg/bower.json` | [Bower package file](http://bower.io/docs/creating-packages/) (optional). We recommend providing this unless your helper depends on a JavaScript and/or CSS module that does not exist [on Bower](http://bower.io/search/). | 74 | | `/helpers/widget.pkg/nuget.nuspec` | [NuGet package file (nuspec)](https://docs.nuget.org/create/nuspec-reference) (optional). We recommend providing this unless your helper depends on a JavaScript and/or CSS module that does not exist on [NuGet Gallery](https://www.nuget.org/). | 75 | | `/helpers/widget.pkg/package.json` | [NPM package file](https://docs.npmjs.com/files/package.json) (optional). We recommend providing this unless your helper depends on a JavaScript and/or CSS module that does not exist on [NPM](https://www.npmjs.com/). | 76 | | `/helpers/widget.pkg/LICENSE` | License file (optional). If not provided, the MIT license file in the root of the project will be copied into your module. | 77 | 78 | 79 | ##### Dialogs 80 | 81 | | Directory | Description | 82 | | ------------- | ------------- | 83 | | `/dialogs/widget.js` | Dialog code file (required) (must follow the UMD) | 84 | | `/dialogs/widget.pkg/README.md` | Readme for your dialog (required). Please provide a description, complete instructions on how to obtain and use the module, its prerequisites, and how to install/reference via CDN. Note that if you use package managers, you can provide dependency information and the prerequisites can be installed automatically, so the documentation will be simpler. | 85 | | `/dialogs/widget.pkg/bower.json` | [Bower package file](http://bower.io/docs/creating-packages/) (optional). We recommend providing this unless your dialog depends on a JavaScript and/or CSS module that does not exist [on Bower](http://bower.io/search/). | 86 | | `/dialogs/widget.pkg/nuget.nuspec` | [NuGet package file (nuspec)](https://docs.nuget.org/create/nuspec-reference) (optional). We recommend providing this unless your dialog depends on a JavaScript and/or CSS module that does not exist on [NuGet Gallery](https://www.nuget.org/). | 87 | | `/dialogs/widget.pkg/package.json` | [NPM package file](https://docs.npmjs.com/files/package.json) (optional). We recommend providing this unless your dialog depends on a JavaScript and/or CSS module that does not exist on [NPM](https://www.npmjs.com/). | 88 | | `/dialogs/widget.pkg/LICENSE` | License file (optional). If not provided, the MIT license file in the root of the project will be copied into your module. | 89 | 90 | 91 | #### Submodules 92 | 93 | We distribute the packages through the use of Git submodules. There is no need for you to add a submodule to your contribution, we will do that for you (one that we own). But do note that the readme will be automatically copied to the distribution repository (submodule) when we do a build. -------------------------------------------------------------------------------- /tests/env.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dirty Forms testing page 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 42 | 133 | 134 | 135 | 136 |

Plain Link

137 |

Ignore Link

138 |

Modal Link (Remote HTML Page)

139 |

Modal Link (Local Form)

140 | 141 |
142 |
143 | Form 1 144 |
145 |
146 |
147 |
148 | 149 |

150 |
151 |
152 | 153 |
154 |
155 | Form 2 156 |
157 |

158 |
159 |
160 |
161 |
162 | Form 3 (TinyMCE Helper) 163 |
164 |

165 |
166 |
167 | 168 | 169 |
170 |
171 |
172 |
173 | Form in a Dialog 174 |
175 |

176 | 177 | 178 |

179 |

180 | 181 | 182 |

183 |

184 | 185 | 191 |

192 |
193 |
194 |

195 | 196 | 202 |

203 |

204 | 205 | 206 |

207 |

208 | 209 | 210 | 211 | 212 |

213 |
214 |

215 | 216 | 217 |

218 | 219 |
220 | 221 |

222 | 223 |
224 |

Me, I'm just a link somewhere

225 |
226 |
227 | 228 | 229 | 230 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 2 | 3 | # Releases 4 | 5 | This document covers both the versioning process and the release procedure. 6 | 7 | ## Versioning 8 | 9 | We are using [semantic versioning](http://semver.org/). As per the document, modifications to the codebase must be separated into 3 main categories. So it follows that the release procedure will include 3 different types of releases. 10 | 11 | 1. ### Patch Releases 12 | 13 | Patches are for backward compatible bug fixes. A patch must not make any modifications to the public API. This may include things that do not modify the codebase directly, such as updating documentation or the build script. 14 | 15 | Each patch should be put into its own branch, and the branch should be named in the format `patch-x`, where x is either the GitHub issue number or, if no issue exists, a short descriptive name of the fix. 16 | 17 | A patch release will simply increment the patch version. For example, a patch to `2.0.1` would increment the number to `2.0.2`. 18 | 19 | 2. ### Minor Releases 20 | 21 | A minor release may have new features added to the codebase that do not break backward compatibility. This means when someone upgrades there should be no code changes necessary to complete the upgrade, and the expected behavior of existing code should be the same. 22 | 23 | A minor release will increment the minor version and reset the patch version to 0. For example, a minor release at the current version `2.0.1` would increment the number to `2.1.0`. 24 | 25 | 3. ### Major Releases 26 | 27 | A major release may contain features that are not backward compatible. However, it is still best to keep backward compatibility if possible. The major release is the time to remove a deprecated feature provided that ample time has passed since the end users were notified the feature is deprecated. It is also the time to add features that change (correct bad) behavior that can potentially break the end users' applications. 28 | 29 | A major release will increment the major version number and reset both the minor and patch version to 0. For example a major release at the current version `2.1.2` would increment the version to `3.0.0`. 30 | 31 | Major releases should not just happen automatically when there is a feature that belongs in a major release. They should contain several features and feature requests that are contributed by the community. A good strategy is to open an issue and request feedback for ideas about what to change, since during a major release there is the most flexibility about what kinds of features can be implemented, then give the community some time (weeks) to respond. 32 | 33 | ## Features 34 | 35 | When working with features, use a separate branch for each new feature. Each branch should be prefixed with `feature-` followed by either an issue number (if applicable) or a short descriptive name of the feature. When the feature is complete, it should be tested/reviewed to determine if any non-backward-compatible change has been made and altered (if possible) to make it backward compatible. 36 | 37 | If the feature is not backward compatible, its branch prefix should be changed (by renaming the branch) from `feature-` to `vnext-`. In general, these branches should be committed to the main repository and accumulated until there is enough reason to perform a major release, allowing minor releases and patches to take precedence. 38 | 39 | ## Preparing for a Release 40 | 41 | First, determine whether a patch, minor, or major release is required (see the [Versioning](#versioning) section above). If you have a mix of patches and minor features to release, it is best to do a patch release first followed by a minor release. Similarly, you should do a release with patches and minor features before doing a major release. 42 | 43 | Once you have determined what features will go into each release (and in what order) merge the changes from the first batch into the `master` branch and fix any merge conflicts accordingly. If you have any additional releases to do, wait until after the first release is complete before starting the additional releases, so they are committed to the repository in the right sequence. 44 | 45 | > **NOTE:** You should never need to update the distribution repositories directly. There is a copy of each of the files that will be deployed there in the development repository that you can edit as needed before the release. All changes flow from the development (central) repository to the distribution repositories during a release, the flow of assets should always be one-way. 46 | 47 | Before each release, you should test the merged code to ensure it functions in each major browser (Chrome, Fireforx, IE, and Safari). Each feature/patch should be tested to ensure it accomplishes the desired behavior when merged with the other features in the release. 48 | 49 | You should also run JSHint on the code and fix any problems it identifies by running the following commands at the root directory of the project. 50 | 51 | ``` 52 | npm install 53 | npm test 54 | ``` 55 | 56 | ## Release Procedure 57 | 58 | > **NOTE:** Releases can only be done using the `master` branch. 59 | 60 | 1. Follow the steps in [Preparing for a Release](#preparing-for-a-release) to update the master branch in your local repository. 61 | 62 | 2. Review the commits in the central repository's `master` branch. Leave the browser window open so you can more easily identify the new commits. This will be necessary later to create a change log. 63 | 64 | 3. Push the code to the `master` branch in the central repository at https://github.com/snikch/jquery.dirtyforms 65 | 66 | > **NOTE:** Collaborator permission is required to perform this. 67 | 68 | 4. Login to the [jquery.dirtyforms MyGet feed](https://www.myget.org/BuildSource/List/jquery-dirtyforms) (you should navigate to the `Build Services` page). 69 | 70 | > **NOTE:** Permission is required to perform this. If you don't have permission, please create an account at MyGet and [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) to request permission (collaborators only). 71 | 72 | 5. Next to the `snikch/jquery.dirtyforms` build source, click the edit icon (the little pencil). 73 | 74 | **Patch Release:** Review that the settings are correct to produce the next patch version (should be, but it's always good to double-check). 75 | 76 | **Minor Release:** Click `reset` on the build counter. Increment the minor version in the `Version format` field. 77 | 78 | Example: Change `2.1.{0}` to `2.2.{0}`. 79 | 80 | **Major Release:** Click `reset` on the build counter. Increment the major version in the `Version format` field and set the minor version to `0`. 81 | 82 | Example: Change `2.1.{0}` to `3.0.{0}`. 83 | 84 | Click `Cancel` if you didn't change anything or `Save` if you did. 85 | 86 | > **NOTE:** You may need to resize the browser in order to see the save and cancel buttons. 87 | 88 | 6. Click the build button and then wait for the build to complete (around 5 - 10 minutes...time to get some coffee). 89 | 90 | 7. If the build failed, you can click the word `failed` to review the (pretty detailed) build log to determine what is amiss. But as long as you didn't update the `gulpfile.js` or `package.json` file in the root of the project, you should be seeing `successful`. 91 | 92 | 8. Perform steps necessary for deployment of package managers/CDN 93 | 94 | **NPM:** Click the [Packages tab](https://www.myget.org/feed/Packages/jquery-dirtyforms) in MyGet. Click the `Push Latest...` button. In the dropdown, choose `Npm packages`. The "Push package to another feed" dialog will appear. Leave the default settings. Click the `Push` button. The packages should appear on [NPM](https://www.npmjs.com/search?q=jquery.dirtyforms) in about 10-15 minutes. 95 | 96 | **NuGet:** Click the [Packages tab](https://www.myget.org/feed/Packages/jquery-dirtyforms) in MyGet. Click the `Push Latest...` button. In the dropdown, choose `NuGet packages`. The "Push package to another feed" dialog will appear. Leave the default settings. Click the `Push` button. The packages should appear on [NuGet Gallery](https://www.nuget.org/packages?q=jquery.dirtyforms) in about 5-10 minutes. 97 | 98 | **Bower:** The build process created a Git tag with the version number. No additional steps are required. 99 | 100 | **jsDelivr:** The jsDeliver bot will automatically detect the Git tag with the version number. No additional steps are required. The bot may take 10 minutes or so to copy the assets of the new version to the CDN, after which you can verify it by copying and pasting `//cdn.jsdelivr.net/g/jquery.dirtyforms@1.1.0` into the browser and replacing the version number at the end with the version number of the current release. 101 | 102 | 9. Update the change log. 103 | 104 | 1. Open a **new browser window/tab** and review the commits in the central repository's `master` branch. 105 | 106 | 2. Compare it against the browser window/tab that you opened in step 2 and identify the commits that were added to this release. 107 | 108 | 3. Click here to draft a new release in a new window/tab. 109 | 110 | 4. Select the version number of this release from the `Tag version` dropdown. 111 | 112 | 5. Copy and paste the version number into the `Release title`. 113 | 114 | 6. Add the header `### Change Log`. 115 | 116 | 7. Summarize the commits in the release by doing the following: 117 | 118 | 1. Add an ordered list of items prefixed with `Bug:`, `Feature:`, `Enhancement:`, `Documentation:`, etc. 119 | 120 | 2. Include the issue number in the format `#51` (to auto link to issue/pull request 51) if it applies. 121 | 122 | 3. Add a brief description of the task that was completed. 123 | 124 | 8. **(optional)** Add any known issues or potential breaking changes with this version. 125 | 126 | 10. **(optional)** Tweet and/or blog about the new release. Tell your buddies at the bar, whatever. 127 | 128 | Then, start working on the next release... (rinse and repeat). -------------------------------------------------------------------------------- /dialogs/bootstrap.pkg/README.md: -------------------------------------------------------------------------------- 1 | [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) 2 | 3 | ![Dirty Forms Logo](https://raw.githubusercontent.com/snikch/jquery.dirtyforms/master/branding/dirty-forms-logo.png) 4 | 5 | # jquery.dirtyforms.dialogs.bootstrap 6 | 7 | This is a dialog module for the [jQuery Dirty Forms](https://github.com/snikch/jquery.dirtyforms) project. 8 | 9 | ## Purpose 10 | 11 | This module causes Dirty Forms to use Bootstrap Modal as its dialog when the user attempts to leave the page by clicking a hyperlink (but not when interacting with the navigation buttons of the browser). 12 | 13 | > Only 1 dialog module can be used by Dirty Forms at a time. The default behavior without this package is to use the browser's built in dialog that is fired by the `beforeunload` event. 14 | 15 | ## Prerequisites 16 | 17 | Prerequesites must be included in this order: 18 | 19 | - [jQuery](http://jquery.com) (>= 1.9.1) 20 | - [bootstrap](http://getbootstrap.com/) (>= 3.0.0) - both the CSS and JS 21 | - [jquery.dirtyforms](https://github.com/snikch/jquery.dirtyforms) (>= 1.0.0) 22 | 23 | > If you are using a [Package Manager](#package-managers), these dependencies will be installed automatically, but depending on your environment you may still need to add references to them manually. 24 | 25 | ## Download & Installation 26 | There are several different ways to get the code. Some examples below: 27 | 28 | #### CDN 29 | The Bootstrap Modal dialog module is available over jsDelivr CDN and can directly be included on every page. 30 | ```HTML 31 | 32 | ``` 33 | 34 | jsDelivr also supports [on-the-fly concatenation of files](https://github.com/jsdelivr/jsdelivr#load-multiple-files-with-single-http-request), so you can reference only 1 URL to get jQuery, bootstrap, jquery.dirtyforms, and jquery.dirtyforms.dialogs.bootstrap in one request. 35 | ```HTML 36 | 37 | ``` 38 | 39 | #### Self-Hosted 40 | Download and save one of two available files to include the Bootstrap Modal dialog module to your page, either the [latest distribution](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.bootstrap.dist/master/jquery.dirtyforms.dialogs.bootstrap.js) or the [latest minified](https://raw.githubusercontent.com/NightOwl888/jquery.dirtyforms.dialogs.bootstrap.dist/master/jquery.dirtyforms.dialogs.bootstrap.min.js) version. 41 | ```HTML 42 | 43 | ``` 44 | 45 | You can also conveniently get all of the latest Dirty Forms files in one [Zip Download](https://github.com/NightOwl888/jquery.dirtyforms.dist/archive/master.zip). 46 | 47 | #### Package Managers 48 | The Bootstrap Modal dialog module is even available through [NPM](http://npmjs.org), [Bower](http://bower.io), and [NuGet](https://www.nuget.org/). Just use one of the following commands below to install the dialog module, including all dependencies. 49 | 50 | [![NPM version](https://badge.fury.io/js/jquery.dirtyforms.dialogs.bootstrap.svg)](http://www.npmjs.org/package/jquery.dirtyforms.dialogs.bootstrap) 51 | [![Bower version](https://badge.fury.io/bo/jquery.dirtyforms.dialogs.bootstrap.svg)](http://bower.io/search/?q=jquery.dirtyforms.dialogs.bootstrap) 52 | [![NuGet version](https://badge.fury.io/nu/jquery.dirtyforms.dialogs.bootstrap.svg)](https://www.nuget.org/packages/jquery.dirtyforms.dialogs.bootstrap/) 53 | 54 | [![NPM](https://nodei.co/npm/jquery.dirtyforms.dialogs.bootstrap.png?compact=true)](https://nodei.co/npm/jquery.dirtyforms.dialogs.bootstrap/) 55 | ``` 56 | // NPM 57 | $ npm install jquery.dirtyforms.dialogs.bootstrap 58 | 59 | // Bower 60 | $ bower install jquery.dirtyforms.dialogs.bootstrap 61 | 62 | // NuGet 63 | PM> Install-Package jquery.dirtyforms.dialogs.bootstrap 64 | ``` 65 | 66 | ## SourceMaps 67 | 68 | A [SourceMap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1) file is also available via CDN or your favorite package manager. 69 | 70 | #### CDN 71 | 72 | ```HTML 73 | 74 | ``` 75 | 76 | #### Package Managers 77 | 78 | NPM, Bower, and NuGet will install the SourceMap file into the destination directory. 79 | 80 | ``` 81 | jquery.dirtyforms.dialogs.bootstrap.min.js.map 82 | ``` 83 | 84 | ## Usage 85 | 86 | This dialog module is automatic. Simply include the reference to the dialog module after the [prerequisites](#prerequisites) and use Dirty Forms [as per the documentation](https://github.com/snikch/jquery.dirtyforms#usage) and Bootstrap Modal [as per the documentation](http://getbootstrap.com/javascript/#modals). However, it is also possible to [customize the HTML](#customization). 87 | 88 | ```HTML 89 | // CSS 90 | 91 | 92 | // JavaScript 93 | 94 | 95 | 96 | 97 | ``` 98 | 99 | > If not using a CDN, you need to apply the dependencies in the same order as in the example above. 100 | 101 | 102 | 103 | ## Options 104 | 105 | The following options are available to set via **$.DirtyForms.dialog.OPTIONNAME = OPTIONVALUE** or get via **OPTIONVALUE = $.DirtyForms.dialog.OPTIONNAME** 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 |
NameTypeDefaultDescription
titlestring' Are you sure you want to do that?'Sets the title of the dialog. Supports HTML.
proceedButtonClassstring'dirty-proceed'Sets the CSS class of the continue button of the dialog (an HTML button tag element). The element with this class will automatically have the proceedButtonText inserted into it and a click event handler bound to it before showing the dialog.
proceedButtonTextstring'Leave This Page'Sets the text of the continue button of the dialog.
stayButtonClassstring'dirty-stay'Sets the CSS class of the cancel button of the dialog (an HTML button tag element). The element with this class will automatically have the stayButtonText inserted into it before showing the dialog.
stayButtonTextstring'Stay Here'Sets the text of the cancel button of the dialog.
dialogIDstring'dirty-dialog'Sets the ID of the outermost element of the dialog. If there is an element with this ID on the page, it will be used for the dialog. If not, a default dialog will be automatically generated.
titleIDstring'dirty-title'Sets the ID of the element that represents the dialog title. The element with this ID will automatically have the title text inserted into it before showing the dialog.
messageClassstring'dirty-message'Sets the CSS class of the element that represents the message body. The element with this class will automatically have the message inserted into it before showing the dialog.
preMessageTextstring''Sets the text that precedes the message text. May contain HTML.
postMessageTextstring''Sets the text that follows the message text. May contain HTML.
replaceTextbooleantrueSet to false to prevent the title, message, continue button text, and cancel button text in the dialog from being overwritten by the configured values. This is useful if you want to configure your dialog text entirely in the HTML of the page.
181 | 182 | > Setting the width of the bootstrap modal requires custom CSS to ensure it will work with different viewport sizes. See [this page](http://coolestguidesontheplanet.com/bootstrap/modal.php) for examples. 183 | 184 | 185 | ## Customization 186 | 187 | Because Bootstrap requires ultimate control over the HTML in order to function, it is possible to provide your own HTML either directly into the page or via JavaScript. Simply add it to the page and ensure that the following match what is specified in the options. 188 | 189 | 1. dialogID (required) 190 | 2. titleID (optional) 191 | 3. messageClass (optional) 192 | 3. proceedButtonClass (required) 193 | 4. stayButtonClass (optional) 194 | 195 | 196 | ### Example 197 | 198 | ```javascript 199 | 200 | $('').appendTo('body'); 218 | 219 | 220 | $('form').dirtyForms({ 221 | // Message will be shown both in the Bootstrap Modal dialog 222 | // and in most browsers when attempting to navigate away 223 | // using browser actions. 224 | message: 'This is a custom message', 225 | dialog: { 226 | title: 'This is a custom title', 227 | dialogID: 'custom-dialog', 228 | titleID: 'custom-title', 229 | messageClass: 'custom-message', 230 | proceedButtonClass: 'custom-proceed', 231 | stayButtonClass: 'custom-stay' 232 | } 233 | }); 234 | 235 | // If .dirtyForms() has already been called, you can override 236 | // the values after the fact like this. 237 | $.DirtyForms.dialog.title = 'This is an alternative custom title'; 238 | 239 | ``` 240 | 241 | 242 | ## Support 243 | 244 | For help or to report a bug please [open an issue](https://github.com/snikch/jquery.dirtyforms/issues/new) at the [Dirty Forms development site](https://github.com/snikch/jquery.dirtyforms/). -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var del = require('del'), 2 | fs = require('fs'), 3 | glob = require('glob'), 4 | gulp = require('gulp'), 5 | bump = require('gulp-bump'), 6 | git = require('gulp-git'), 7 | gulpif = require('gulp-if'), 8 | ignore = require('gulp-ignore'), 9 | jshint = require('gulp-jshint'), 10 | rename = require('gulp-rename'), 11 | replace = require('gulp-replace'), 12 | sourcemaps = require('gulp-sourcemaps'), 13 | tap = require('gulp-tap'), 14 | uglify = require('gulp-uglify'), 15 | stylish = require('jshint-stylish'), 16 | lazypipe = require('lazypipe'), 17 | merge = require('merge-stream'), 18 | path = require('path'), 19 | request = require('request'), 20 | runSequence = require('run-sequence'), 21 | shell = require('shelljs'); 22 | var args = require('yargs').argv; 23 | 24 | var settings = { 25 | baseProject: 'jquery.dirtyforms', 26 | src: ['./jquery.dirtyforms.js', './helpers/*.js', './dialogs/*.js'], 27 | src_assets: ['./README.md', './pkg/*.json'], 28 | src_module_assets: ['./@(helpers|dialogs)/**/*.json', './@(helpers|dialogs)/**/README.md', './@(helpers|dialogs)/**/LICENSE*'], 29 | src_json_files: ['./**/*.json', '!./node_modules/**', '!./dist/**'], 30 | src_readme_files: ['./**/README*', '!./dist/**'], 31 | dest: './dist/', 32 | dest_plugins: '/plugins', 33 | nugetPath: './nuget.exe', 34 | subModules: [], // All of the git submodule names (individual releases) for the build 35 | version: '', 36 | debug: true 37 | }; 38 | 39 | settings.subModules = getSubmoduleNames(); 40 | settings.version = getBuildVersion(); 41 | settings.debug = getDebug(); 42 | 43 | console.log('subModules: ' + settings.subModules); 44 | console.log('Debug mode: ' + settings.debug); 45 | 46 | 47 | // Builds the distribution files and packs them with NuGet 48 | gulp.task('default', ['clean', 'test'], function (cb) { 49 | runSequence( 50 | 'git-checkout', 51 | 'pack', 52 | cb); 53 | }); 54 | 55 | // Cleans the distribution folders 56 | gulp.task('clean', function (cb) { 57 | del([settings.dest + '**/*.js', 58 | settings.dest + '**/*.map', 59 | settings.dest + '**/*.nupkg', 60 | settings.dest + '**/*.tgz', 61 | settings.dest + '**/*.css', 62 | settings.dest + '**/*.png', 63 | settings.dest + '**/*.gif', 64 | settings.dest + '**/README.*', 65 | settings.dest + '**/LICENSE.*', 66 | settings.dest + '**/*.json'], cb); 67 | }); 68 | 69 | // Moves the .js files to the distribution folders and creates a minified version and sourcemap 70 | gulp.task('build', ['copy-minified'], function (cb) { 71 | del([settings.dest + '*.js', settings.dest + '*.map'], cb); 72 | }); 73 | 74 | gulp.task('umd-build', ['umd-copy-minified'], function (cb) { 75 | del([settings.dest + '*.js', settings.dest + '*.map'], cb); 76 | }); 77 | 78 | // Tests the source files (smoke test) 79 | gulp.task('test', function () { 80 | return gulp.src(settings.src, { base: './' }) 81 | .pipe(jshint()) 82 | .pipe(jshint.reporter(stylish)); 83 | }); 84 | 85 | gulp.task('copy-minified', ['uglify', 'distribute-module-assets'], function () { 86 | return doCopyMinified(false); 87 | }); 88 | 89 | gulp.task('umd-copy-minified', ['umd-uglify', 'distribute-module-assets'], function () { 90 | return doCopyMinified(true); 91 | }); 92 | 93 | gulp.task('uglify', function () { 94 | return doUglify(false); 95 | }); 96 | 97 | gulp.task('umd-uglify', function () { 98 | return doUglify(true); 99 | }); 100 | 101 | 102 | gulp.task('distribute-default-license', function () { 103 | var defaultLicense = './LICENSE*'; 104 | var baseModule = gulp.src(defaultLicense, { base: './' }) 105 | .pipe(rename(function (path) { 106 | path.dirname = settings.baseProject; 107 | })) 108 | .pipe(gulp.dest(settings.dest)); 109 | 110 | var merged = merge(baseModule); 111 | var modulesLength = settings.subModules.length; 112 | for (var i = 0; i < modulesLength; i++) { 113 | var subModule = settings.subModules[i]; 114 | var module = gulp.src(defaultLicense, { base: './' }) 115 | .pipe(ignore(settings.baseProject)) 116 | .pipe(gulp.dest(settings.dest + subModule)); 117 | 118 | merged.add(module); 119 | } 120 | 121 | return merged; 122 | }); 123 | 124 | gulp.task('distribute-assets', ['distribute-default-license'], function () { 125 | return gulp.src(settings.src_assets, { base: './' }) 126 | .pipe(rename(function (path) { 127 | path.dirname = settings.baseProject; 128 | })) 129 | .pipe(gulp.dest(settings.dest)); 130 | }); 131 | 132 | gulp.task('distribute-module-assets', ['distribute-assets'], function () { 133 | return gulp.src(settings.src_module_assets, { base: './' }) 134 | .pipe(rename(function (path) { 135 | var segments = path.dirname.split(/[/\\]/); 136 | var rootDir = segments[0]; 137 | if (rootDir == 'helpers' || rootDir == 'dialogs') { 138 | console.log('moving: ' + path.dirname + '/' + path.basename + '.' + path.extname); 139 | var pkgDir = segments[1].replace('.pkg', ''); 140 | path.dirname = settings.baseProject + '.' + rootDir + '.' + pkgDir; 141 | } 142 | })) 143 | .pipe(gulp.dest(settings.dest)); 144 | }); 145 | 146 | // Runs the build, downloads the NuGet.exe file, and packs the distribution files with NuGet 147 | gulp.task('nuget-pack', ['nuget-download', 'build'], function (cb) { 148 | console.log('build version: ' + settings.version); 149 | 150 | // Get the nuspec files 151 | var nuspecFiles = glob.sync("./**/*.nuspec"); 152 | 153 | console.log('Nuspec files: ' + nuspecFiles); 154 | 155 | var nuspecLength = nuspecFiles.length; 156 | for (var i = 0; i < nuspecLength; i++) { 157 | var nuspecFile = nuspecFiles[i]; 158 | var absoluteNuspecFile = path.resolve(nuspecFile); 159 | var absoluteNugetPath = path.resolve(settings.nugetPath); 160 | var absoluteDistributionFolder = path.resolve(settings.dest); 161 | 162 | // Pack NuGet file 163 | if (shell.exec('"' + absoluteNugetPath + '" pack "' + absoluteNuspecFile + '" -Version ' + settings.version + ' -OutputDirectory "' + absoluteDistributionFolder + '"').code != 0) { 164 | shell.echo('Error: NuGet pack failed for ' + absoluteNuspecFile); 165 | shell.exit(1); 166 | } 167 | } 168 | 169 | cb(); 170 | }); 171 | 172 | gulp.task('nuget-download', function () { 173 | if (fs.existsSync(settings.nugetPath)) { 174 | done(); 175 | return; 176 | } 177 | 178 | return request.get('http://nuget.org/nuget.exe') 179 | .pipe(fs.createWriteStream(settings.nugetPath)) 180 | .on('close', done); 181 | }); 182 | 183 | gulp.task('npm-pack', ['umd-build'], function (cb) { 184 | var modulesLength = settings.subModules.length; 185 | var relativeDestPath = path.relative('./', settings.dest); 186 | for (var i = 0; i < modulesLength; i++) { 187 | var subModule = settings.subModules[i]; 188 | var cwd = settings.dest + subModule; 189 | var relativeWorkingPath = path.relative('./', cwd); 190 | 191 | if (fs.existsSync(cwd + '/package.json')) { 192 | 193 | console.log('Packing ' + relativeWorkingPath + ' for NPM...'); 194 | if (shell.exec('cd "' + relativeDestPath + '" && npm pack "' + subModule + '"').code != 0) { 195 | shell.echo('Error: NPM pack for ' + relativeWorkingPath + ' failed'); 196 | shell.exit(1); 197 | } 198 | } 199 | } 200 | cb(); 201 | }); 202 | 203 | gulp.task('pack', ['clean', 'test'], function (cb) { 204 | // Because NPM distribution files will have UMD support, 205 | // we run the whole sequence to package it up first, then 206 | // run the command to package NuGet files (after which 207 | // the directory structure will be correct for checking in 208 | // and distributing to CDNs). 209 | runSequence( 210 | 'npm-pack', 211 | 'nuget-pack', 212 | cb); 213 | }); 214 | 215 | 216 | gulp.task('bump-version', function () { 217 | var argsVersion = args.version; 218 | var buildType = args.buildType; 219 | var preid = args.preid; 220 | 221 | console.log('build type: ' + buildType); 222 | 223 | if (typeof (argsVersion) == 'undefined') { 224 | return gulp.src(settings.src_json_files, { base: './' }) 225 | .pipe(bump({ type: buildType })) 226 | .pipe(tap(function (file, t) { 227 | var newPkg = JSON.parse(file.contents.toString()); 228 | settings.version = newPkg.version; 229 | })) 230 | .pipe(gulp.dest('./')); 231 | } 232 | else { 233 | return gulp.src(settings.src_json_files, { base: './' }) 234 | .pipe(bump({ version: settings.version, preid: preid })) 235 | .pipe(gulp.dest('./')); 236 | } 237 | }); 238 | 239 | gulp.task('bump-source-version', ['bump-version'], function () { 240 | return gulp.src(settings.src, { base: './' }) 241 | // Replace the version number in the header comment 242 | // and in the CDN URLs 243 | .pipe(replace(eval('/v\\s*?\\d+\\.\\d+\\.\\d+(?:-\\w+)?/g'), 'v' + settings.version)) 244 | .pipe(gulp.dest('.')); 245 | }); 246 | 247 | gulp.task('bump-readme-version', ['bump-source-version'], function () { 248 | return gulp.src(settings.src_readme_files, { base: './' }) 249 | // Replace the version number in the CDN URLs 250 | .pipe(replace(eval('/\\/' + settings.baseProject + '\\/\\d+\\.\\d+\\.\\d+(?:-\\w+)?\\//g'), '/' + settings.baseProject + '/' + settings.version + '/')) 251 | .pipe(replace(eval('/' + settings.baseProject + '\\@\\d+\\.\\d+\\.\\d+(?:-\\w+)?/g'), settings.baseProject + '@' + settings.version)) 252 | .pipe(gulp.dest('.')); 253 | }); 254 | 255 | // Bumps the version number. 256 | // CLI args: 257 | // --version=1.0.0 // sets the build to a specific version number 258 | // --buildType=minor // if the version is not specified, increments the minor version and resets the patch version to 0 259 | // // allowed values: major, minor, patch 260 | gulp.task('bump', ['bump-readme-version'], function (cb) { 261 | console.log('Successfully bumped version to: ' + settings.version); 262 | cb(); 263 | }); 264 | 265 | // Writes the current version of Git to the console 266 | gulp.task('git-version', function (cb) { 267 | if (shell.exec('git --version').code != 0) { 268 | shell.echo('Error: Git --version failed'); 269 | shell.exit(1); 270 | } 271 | else { 272 | cb(); 273 | } 274 | }); 275 | 276 | gulp.task('git-submodule-reset', function (cb) { 277 | var modulesLength = settings.subModules.length; 278 | for (var i = 0; i < modulesLength; i++) { 279 | var subModule = settings.subModules[i]; 280 | var cwd = settings.dest + subModule; 281 | var relativeWorkingPath = path.relative('./', cwd); 282 | 283 | console.log('Resetting Git submodule ' + relativeWorkingPath + '...'); 284 | if (shell.exec('cd "' + relativeWorkingPath + '" && git reset --hard HEAD').code != 0) { 285 | shell.echo('Error: Git reset failed for ' + relativeWorkingPath); 286 | shell.exit(1); 287 | } else { 288 | console.log('Cleaning Git submodule ' + relativeWorkingPath + '...'); 289 | if (shell.exec('cd "' + relativeWorkingPath + '" && git clean -fd').code != 0) { 290 | shell.echo('Error: Git clean failed for ' + relativeWorkingPath); 291 | shell.exit(1); 292 | } 293 | } 294 | } 295 | 296 | cb(); 297 | }); 298 | 299 | gulp.task('git-reset', ['git-submodule-reset'], function (cb) { 300 | console.log('Resetting main module...'); 301 | git.reset('HEAD', {args:'--hard', cwd: './'}, function (err) { 302 | if (!err) { 303 | console.log('Cleaning main module...'); 304 | git.exec({ args: 'clean -fd', cwd: './' }, cb); 305 | } 306 | }); 307 | }); 308 | 309 | gulp.task('git-submodule-update-init', function (cb) { 310 | git.updateSubmodule({ args: '--init --recursive', cwd: './' }, cb); 311 | }); 312 | 313 | gulp.task('git-submodule-checkout', ['git-submodule-update-init'], function (cb) { 314 | var modulesLength = settings.subModules.length; 315 | for (var i = 0; i < modulesLength; i++) { 316 | var subModule = settings.subModules[i]; 317 | var cwd = settings.dest + subModule; 318 | var relativeWorkingPath = path.relative('./', cwd); 319 | 320 | console.log('Checking Out Git submodule ' + relativeWorkingPath + '...'); 321 | if (shell.exec('cd "' + relativeWorkingPath + '" && git checkout master').code != 0) { 322 | shell.echo('Error: Git checkout failed for ' + relativeWorkingPath); 323 | shell.exit(1); 324 | } 325 | } 326 | 327 | cb(); 328 | }); 329 | 330 | gulp.task('git-checkout', ['git-submodule-checkout'], function (cb) { 331 | if (settings.debug == false) { 332 | git.checkout('master', { cwd: './' }, cb); 333 | } else { 334 | cb(); 335 | } 336 | }); 337 | 338 | gulp.task('git-release-modules', function (cb) { 339 | var modulesLength = settings.subModules.length; 340 | for (var i = 0; i < modulesLength; i++) { 341 | var subModule = settings.subModules[i]; 342 | var cwd = settings.dest + subModule; 343 | var relativeWorkingPath = path.relative('./', cwd); 344 | 345 | console.log('Adding files to Git submodule ' + relativeWorkingPath + '...'); 346 | if (shell.exec('cd "' + relativeWorkingPath + '" && git add -A').code != 0) { 347 | shell.echo('Error: Git add failed for ' + relativeWorkingPath); 348 | shell.exit(1); 349 | } 350 | else { 351 | console.log('Committing files to Git submodule ' + relativeWorkingPath + '...'); 352 | if (shell.exec('cd "' + relativeWorkingPath + '" && git commit -m "Release version ' + settings.version + '"').code != 0) { 353 | shell.echo('Error: Git commit failed for ' + relativeWorkingPath); 354 | shell.exit(1); 355 | } 356 | else { 357 | console.log('Tagging Git submodule ' + relativeWorkingPath + '...'); 358 | if (shell.exec('cd "' + relativeWorkingPath + '" && git tag ' + settings.version + ' -m "Release version ' + settings.version + '"').code != 0) { 359 | shell.echo('Error: Git tag failed for ' + relativeWorkingPath); 360 | shell.exit(1); 361 | } 362 | else { 363 | console.log('Pushing Git submodule ' + relativeWorkingPath + '...'); 364 | if (shell.exec('cd "' + relativeWorkingPath + '" && git push origin master --follow-tags' + ((settings.debug) ? ' --dry-run' : '')).code != 0) { 365 | shell.echo('Error: Git push failed for ' + relativeWorkingPath); 366 | shell.exit(1); 367 | } 368 | } 369 | } 370 | } 371 | } 372 | 373 | cb(); 374 | }); 375 | 376 | gulp.task('git-add', function (cb) { 377 | git.exec({ args: 'add -A', cwd: './' }, cb); 378 | }); 379 | 380 | gulp.task('git-commit', ['git-add'], function (cb) { 381 | if (shell.exec('git commit -m "Release version ' + settings.version + '"').code != 0) { 382 | shell.echo('Error: Git commit failed for ' + settings.baseProject); 383 | shell.exit(1); 384 | } 385 | else { 386 | cb(); 387 | } 388 | }); 389 | 390 | gulp.task('git-tag', ['git-commit'], function (cb) { 391 | git.tag(settings.version, 'Release version ' + settings.version, { cwd: './' }, cb); 392 | }); 393 | 394 | gulp.task('git-submodule-update', ['git-tag'], function (cb) { 395 | git.updateSubmodule({ cwd: './' }, cb); 396 | }); 397 | 398 | gulp.task('git-push', ['git-submodule-update'], function (cb) { 399 | git.push('origin', 'master', { args: '--follow-tags' + ((settings.debug) ? ' --dry-run' : ''), cwd: './' }, cb, function (err) { 400 | if (err) throw err; 401 | }); 402 | }); 403 | 404 | // Performs a release 405 | // 1. Ensures the repository and submodules are up to date 406 | // 2. Bumps the version (can specify version on the CLI, for example: --version=1.0.0-alpha00003, --version=1.2.3) 407 | // 3. Builds the distribution files 408 | // 4. Packages the distribution files with NuGet 409 | // 5. Commits the distribution files 410 | // 6. Tags the repository and all submodules with the release version 411 | // 7. Pushes the repository and all submodules to their origin remote, including tags 412 | gulp.task('release', function (cb) { 413 | runSequence( 414 | 'git-checkout', 415 | 'bump', 416 | 'pack', 417 | 'git-release-modules', 418 | 'git-push', 419 | cb); 420 | }); 421 | 422 | function done() { } 423 | 424 | function getSubmoduleNames() { 425 | var subModules = []; 426 | var baseSubmodule = settings.baseProject; 427 | subModules.push(baseSubmodule); 428 | 429 | // Load helper and dialog names 430 | // http://stackoverflow.com/questions/30623886/get-an-array-of-file-names-without-extensions-from-a-directory-in-gulp/30680952#30680952 431 | glob.sync("@(helpers|dialogs)/*.js") 432 | .forEach(function (file) { 433 | var dirName = path.dirname(file); 434 | var baseName = path.basename(file, path.extname(file)); 435 | var subModule = baseSubmodule + '.' + dirName + '.' + baseName; 436 | subModules.push(subModule); 437 | }); 438 | 439 | return subModules; 440 | }; 441 | 442 | function getBuildVersion() { 443 | var packageVersion = getPackageJsonVersion(); 444 | var argsVersion = args.version; 445 | 446 | console.log('config version: ' + packageVersion); 447 | console.log('args version: ' + argsVersion); 448 | 449 | // Override the version number with the CLI argument --version=1.2.3 450 | if (typeof (argsVersion) !== 'undefined') { 451 | return argsVersion; 452 | } 453 | 454 | return packageVersion; 455 | }; 456 | 457 | function getPackageJsonVersion() { 458 | //We parse the json file instead of using require because require caches multiple calls so the version number won't be updated 459 | return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; 460 | }; 461 | 462 | function getDebug() { 463 | var argsDebug = args.debug; 464 | 465 | // Override the debug setting with the CLI argument --debug=false 466 | if (typeof (argsDebug) !== 'undefined') { 467 | return argsDebug.toLowerCase() === 'true'; 468 | } 469 | 470 | return settings.debug; 471 | }; 472 | 473 | function doUglify(isUmd) { 474 | var getCommentRegEx = function (tagName) { 475 | return '/(?: |\\t)*?\\/\\*\\s*?<' + tagName + '>\\s*?\\*\\/[\\s\\S]*?\\/\\*\\s*?<\\/' + tagName + '>\\s*?\\*\\//g'; 476 | }; 477 | 478 | return gulp.src(settings.src, { base: './' }) 479 | .pipe(rename(function (path) { 480 | var baseName = path.basename; 481 | var dirName = path.dirname; 482 | if (dirName == 'helpers' || dirName == 'dialogs') { 483 | path.basename = settings.baseProject + '.' + dirName + '.' + baseName; 484 | } 485 | path.dirname = path.basename; 486 | })) 487 | // If not UMD, remove the IIFE header and footer, and replace with 488 | // compact header and footer 489 | .pipe(gulpif(!isUmd, replace(eval(getCommentRegEx('iife_head')), '(function($, window, document, undefined) {'))) 490 | .pipe(gulpif(!isUmd, replace(eval(getCommentRegEx('iife_foot')), '})(jQuery, window, document);'))) 491 | 492 | .pipe(gulp.dest(settings.dest)) 493 | // Remove log statements from minified code 494 | .pipe(replace(eval(getCommentRegEx('log')), '')) 495 | .pipe(replace(eval('/(?:\\$\\.DirtyForms\\.)?dirtylog\\([\\s\\S]*?\\);/g'), '')) 496 | .pipe(sourcemaps.init()) 497 | .pipe(rename(function (path) { 498 | path.dirname = ''; 499 | path.extname = '.min.js'; 500 | })) 501 | .pipe(uglify({ 502 | outSourceMap: true, 503 | sourceRoot: '/', 504 | preserveComments: 'some' 505 | })) 506 | .pipe(gulp.dest(settings.dest)) 507 | .pipe(sourcemaps.write('.', { 508 | includeContent: true, 509 | sourceRoot: '/' 510 | })) 511 | .pipe(gulp.dest(settings.dest)); 512 | } 513 | 514 | function doCopyMinified(isUmd) { 515 | var copyToCdnChannel = lazypipe() 516 | .pipe(function () { return ignore.exclude(eval('/' + settings.baseProject + '\.min/')); }) 517 | .pipe(function () { 518 | return rename(function (path) { 519 | console.log('moving: ' + path.basename) 520 | path.dirname = settings.baseProject + settings.dest_plugins; 521 | }); 522 | }) 523 | .pipe(function () { return gulp.dest(settings.dest); }); 524 | 525 | return gulp.src([settings.dest + '*.js', settings.dest + '*.map'], { base: './' }) 526 | .pipe(rename(function (path) { 527 | console.log('moving: ' + path.basename) 528 | path.dirname = path.basename.replace(/\.min(?:\.js)?/g, ''); 529 | })) 530 | .pipe(gulp.dest(settings.dest)) 531 | .pipe(gulpif(!isUmd, copyToCdnChannel())); 532 | } -------------------------------------------------------------------------------- /jquery.dirtyforms.js: -------------------------------------------------------------------------------- 1 | /*! 2 | Dirty Forms jQuery Plugin | v2.0.0 | github.com/snikch/jquery.dirtyforms 3 | (c) 2010-2016 Mal Curtis 4 | License MIT 5 | */ 6 | 7 | /**/ 8 | // Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js 9 | // See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. 10 | (function (factory) { 11 | if (typeof define === 'function' && define.amd) { 12 | // AMD. Register as an anonymous module. 13 | define(['jquery', 'window', 'document'], factory); 14 | } else if (typeof module === 'object' && module.exports) { 15 | // Node/CommonJS 16 | module.exports = factory(require('jquery'), window, document); 17 | } else { 18 | // Browser globals 19 | factory(jQuery, window, document); 20 | } 21 | }(function ($, window, document, undefined) { 22 | /**/ 23 | // Can't use ECMAScript 5's strict mode because several apps 24 | // including ASP.NET trace the stack via arguments.caller.callee 25 | // and Firefox dies if you try to trace through "use strict" call chains. 26 | // See jQuery issue (#13335) 27 | // Support: Firefox 18+ 28 | //"use strict"; 29 | 30 | if (!$.fn.on) { 31 | // Patch jQuery 1.4.2 - 1.7 with an on function (that uses delegate). 32 | $.fn.on = function (events, selector, data, handler) { 33 | return this.delegate(selector, events, data, handler); 34 | }; 35 | } 36 | 37 | $.fn.dirtyForms = function (method) { 38 | // Method calling logic 39 | if (methods[method]) { 40 | return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 41 | } else if (typeof method === 'object' || !method) { 42 | return methods.init.apply(this, arguments); 43 | } else { 44 | $.error('Method ' + method + ' does not exist on jQuery.dirtyForms'); 45 | } 46 | }; 47 | 48 | // Public Element methods ( $('form').dirtyForms('methodName', args) ) 49 | var methods = { 50 | init: function (options) { 51 | var data = {}; 52 | 53 | if (!state.initialized) { 54 | // Override any default options 55 | $.extend(true, $.DirtyForms, options); 56 | 57 | $(document).trigger('bind.dirtyforms', [events]); 58 | events.bind(window, document, data); 59 | 60 | state.initialized = true; 61 | } 62 | 63 | this.filter('form').not(':dirtylistening').each(function () { 64 | var $form = $(this); 65 | dirtylog('Adding form ' + $form.attr('id') + ' to forms to watch'); 66 | 67 | // Store original values of the fields 68 | $form.find($.DirtyForms.fieldSelector).each(function () { 69 | storeOriginalValue($(this)); 70 | }); 71 | 72 | $form.trigger('scan.dirtyforms'); 73 | events.bindForm($form, data); 74 | }); 75 | return this; 76 | }, 77 | // Returns true if any of the selected elements or their children are dirty 78 | isDirty: function (excludeHelpers) { 79 | var ignoreSelector = getIgnoreSelector(), 80 | dirtyClass = $.DirtyForms.dirtyClass, 81 | isDirty = false; 82 | 83 | this.each(function (index) { 84 | var $node = $(this), 85 | ignored = isFieldIgnored($node, ignoreSelector); 86 | 87 | if ($node.hasClass(dirtyClass) && !ignored) { 88 | isDirty = true; 89 | // Exit out of the .each() function 90 | return false; 91 | } 92 | 93 | // Check any descendant nodes (if this is a container element) 94 | $node.find('.' + dirtyClass).each(function () { 95 | if (!isFieldIgnored($(this), ignoreSelector)) { 96 | isDirty = true; 97 | // Exit out of the .each() function 98 | return false; 99 | } 100 | }); 101 | // Exit out of the .each() function 102 | if (isDirty) return false; 103 | 104 | if (!ignored && !excludeHelpers) { 105 | // Test helpers for this node. 106 | $.each($.DirtyForms.helpers, function (i, helper) { 107 | if (helper.isDirty && helper.isDirty($node, index)) { 108 | isDirty = true; 109 | // Exit out of the .each() function 110 | return false; 111 | } 112 | }); 113 | 114 | // Exit out of the .each() function 115 | if (isDirty) return false; 116 | } 117 | }); 118 | 119 | return isDirty; 120 | }, 121 | // Marks the element(s) and any helpers within the element not dirty. 122 | // If all of the fields in a form are marked not dirty, the form itself will be marked not dirty even 123 | // if it is not included in the selector. Also resets original values to the current state - 124 | // essentially "forgetting" the node or its descendants are dirty. 125 | setClean: function (excludeIgnored, excludeHelpers) { 126 | dirtylog('setClean called'); 127 | 128 | var doSetClean = function () { 129 | var $field = $(this); 130 | 131 | // Reset by storing the original value again 132 | storeOriginalValue($field); 133 | 134 | // Remove the dirty class 135 | setDirtyStatus($field, false); 136 | }; 137 | 138 | elementsInRange(this, $.DirtyForms.fieldSelector, excludeIgnored) 139 | .each(doSetClean) 140 | .parents('form').trigger('setclean.dirtyforms', [excludeIgnored]); 141 | 142 | if (excludeHelpers) return this; 143 | return fireHelperMethod(this, 'setClean', excludeIgnored, getIgnoreSelector()); 144 | }, 145 | // Scans the selected elements and descendants for any new fields and stores their original values. 146 | // Ignores any original values that had been set previously. Also resets the dirty status of all fields 147 | // whose ignore status has changed since the last scan. 148 | rescan: function (excludeIgnored, excludeHelpers) { 149 | dirtylog('rescan called'); 150 | 151 | var doRescan = function () { 152 | var $field = $(this); 153 | 154 | // Skip previously added fields 155 | if (!hasOriginalValue($field)) { 156 | // Store the original value 157 | storeOriginalValue($field); 158 | } 159 | 160 | // Set the dirty status 161 | setDirtyStatus($field, isFieldDirty($field)); 162 | }; 163 | 164 | elementsInRange(this, $.DirtyForms.fieldSelector, excludeIgnored) 165 | .each(doRescan) 166 | .parents('form').trigger('rescan.dirtyforms', [excludeIgnored]); 167 | 168 | if (excludeHelpers) return this; 169 | return fireHelperMethod(this, 'rescan', excludeIgnored, getIgnoreSelector()); 170 | } 171 | }; 172 | 173 | // Custom selectors $('form:dirty') 174 | $.extend($.expr[":"], { 175 | dirty: function (element) { 176 | var $element = $(element); 177 | return $element.hasClass($.DirtyForms.dirtyClass) && !$element.is(':dirtyignored'); 178 | }, 179 | dirtylistening: function (element) { 180 | return $(element).hasClass($.DirtyForms.listeningClass); 181 | }, 182 | dirtyignored: function (element) { 183 | return isFieldIgnored($(element), false); 184 | } 185 | }); 186 | 187 | // Public General Plugin properties and methods $.DirtyForms 188 | $.DirtyForms = { 189 | message: "You've made changes on this page which aren't saved. If you leave you will lose these changes.", 190 | dirtyClass: 'dirty', 191 | listeningClass: 'dirtylisten', 192 | ignoreClass: 'dirtyignore', 193 | ignoreSelector: '', 194 | // exclude all HTML 4 except checkbox, option, text and password, but include HTML 5 except search 195 | fieldSelector: "input:not([type='button'],[type='image'],[type='submit']," + 196 | "[type='reset'],[type='file'],[type='search']),select,textarea", 197 | /**/ 198 | debug: false, 199 | dirtylog: function (msg) { 200 | dirtylog(msg); 201 | }, 202 | /**/ 203 | helpers: [], 204 | dialog: false 205 | }; 206 | 207 | // Private State Management 208 | var state = { 209 | initialized: false, 210 | formStash: false, 211 | dialogStash: false, 212 | deciding: false, 213 | decidingEvent: false 214 | }; 215 | 216 | // Dialog Decision Management 217 | var choice; 218 | 219 | var bindKeys = function (ev) { 220 | if (ev.data.bindEscKey && ev.which == 27 || ev.data.bindEnterKey && ev.which == 13) { 221 | return doCommit(ev, false); 222 | } 223 | }; 224 | 225 | var bindDialog = function (choice) { 226 | var staySelector = choice.staySelector, 227 | proceedSelector = choice.proceedSelector; 228 | 229 | if (staySelector !== '') { 230 | $(staySelector).unbind('click', doCommit) 231 | .click(doCommit); 232 | } 233 | if (proceedSelector !== '') { 234 | $(proceedSelector).unbind('click', doProceed) 235 | .click(doProceed); 236 | } 237 | if (choice.bindEscKey || choice.bindEnterKey) { 238 | $(document).unbind('keydown', bindKeys) 239 | .keydown(choice, bindKeys); 240 | } 241 | }; 242 | 243 | var callDialogClose = function (proceeding, unstashing) { 244 | if ($.isFunction($.DirtyForms.dialog.close)) { 245 | dirtylog('Calling dialog close'); 246 | $.DirtyForms.dialog.close(proceeding, unstashing); 247 | } 248 | }; 249 | 250 | var doProceed = function (ev) { 251 | return doCommit(ev, true); 252 | }; 253 | 254 | var doCommit = function (ev, proceeding) { 255 | if (!state.deciding) return; 256 | ev.preventDefault(); 257 | 258 | if (proceeding === true) { 259 | var refireEvent = state.decidingEvent; 260 | $(document).trigger('proceed.dirtyforms', [refireEvent]); 261 | events.clearUnload(); // fix for chrome/safari 262 | callDialogClose(proceeding, false); 263 | refire(refireEvent); 264 | } else { 265 | $(document).trigger('stay.dirtyforms'); 266 | var isUnstashing = $.DirtyForms.dialog !== false && state.dialogStash !== false && $.isFunction($.DirtyForms.dialog.unstash); 267 | callDialogClose(proceeding, isUnstashing); 268 | if (isUnstashing) { 269 | dirtylog('Refiring the dialog with stashed content'); 270 | $.DirtyForms.dialog.unstash(state.dialogStash, ev); 271 | } 272 | $(document).trigger('afterstay.dirtyforms'); 273 | } 274 | 275 | state.deciding = state.decidingEvent = state.dialogStash = state.formStash = false; 276 | return false; 277 | }; 278 | 279 | // Event management 280 | var events = { 281 | bind: function (window, document, data) { 282 | $(window).bind('beforeunload', data, events.onBeforeUnload); 283 | $(document).on('click', 'a:not([target="_blank"])', data, events.onAnchorClick) 284 | .on('submit', 'form', data, events.onSubmit); 285 | }, 286 | bindForm: function ($form, data) { 287 | var dirtyForms = $.DirtyForms; 288 | 289 | // Test whether we are dealing with IE < 10 290 | var isIE8_9 = ('onpropertychange' in document.createElement('input')); 291 | var inputEvents = 'change input' + (isIE8_9 ? ' keyup selectionchange cut paste' : ''); 292 | $form.addClass(dirtyForms.listeningClass) 293 | .on('focus keydown', dirtyForms.fieldSelector, data, events.onFocus) 294 | .on(inputEvents, dirtyForms.fieldSelector, data, events.onFieldChange) 295 | .bind('reset', data, events.onReset); 296 | }, 297 | // For any fields added after the form was initialized, store the value when focused. 298 | onFocus: function (ev) { 299 | var $field = $(ev.target); 300 | if (!hasOriginalValue($field)) { 301 | storeOriginalValue($field); 302 | } 303 | }, 304 | onFieldChange: function (ev) { 305 | var $field = $(ev.target); 306 | if (ev.type !== 'change') { 307 | delay(function () { setFieldStatus($field); }, 100); 308 | } else { 309 | setFieldStatus($field); 310 | } 311 | }, 312 | onReset: function (ev) { 313 | var $form = $(ev.target).closest('form'); 314 | // Need a delay here because reset is called before the state of the form is reset. 315 | setTimeout(function () { $form.dirtyForms('setClean'); }, 100); 316 | }, 317 | onAnchorClick: function (ev) { 318 | bindFn(ev); 319 | }, 320 | onSubmit: function (ev) { 321 | bindFn(ev); 322 | }, 323 | onBeforeUnload: function (ev) { 324 | var result = bindFn(ev); 325 | 326 | if (result && state.doubleunloadfix !== true) { 327 | dirtylog('Before unload will be called, resetting'); 328 | state.deciding = false; 329 | } 330 | 331 | state.doubleunloadfix = true; 332 | setTimeout(function () { state.doubleunloadfix = false; }, 200); 333 | 334 | // Only return the result if it is a string, otherwise don't return anything. 335 | if (typeof result === 'string') { 336 | // For IE and Firefox prior to version 4, set the returnValue. 337 | ev.returnValue = result; 338 | return result; 339 | } 340 | }, 341 | onRefireClick: function (ev) { 342 | var event = new $.Event('click'); 343 | $(ev.target).trigger(event); 344 | if (!event.isDefaultPrevented()) { 345 | events.onRefireAnchorClick(ev); 346 | } 347 | }, 348 | onRefireAnchorClick: function (ev) { 349 | var href = $(ev.target).closest('a[href]').attr('href'); 350 | if (href !== undefined) { 351 | dirtylog('Sending location to ' + href); 352 | window.location.href = href; 353 | } 354 | }, 355 | clearUnload: function () { 356 | // I'd like to just be able to unbind this but there seems 357 | // to be a bug in jQuery which doesn't unbind onbeforeunload 358 | dirtylog('Clearing the beforeunload event'); 359 | $(window).unbind('beforeunload', events.onBeforeUnload); 360 | window.onbeforeunload = null; 361 | $(document).trigger('beforeunload.dirtyforms'); 362 | } 363 | }; 364 | 365 | var elementsInRange = function ($this, selector, excludeIgnored) { 366 | var $elements = $this.filter(selector).add($this.find(selector)); 367 | if (excludeIgnored) { 368 | $elements = $elements.not(':dirtyignored'); 369 | } 370 | return $elements; 371 | }; 372 | 373 | var fireHelperMethod = function ($this, method, excludeIgnored, ignoreSelector) { 374 | return $this.each(function (index) { 375 | var $node = $(this); 376 | 377 | if (!excludeIgnored || !isFieldIgnored($node, ignoreSelector)) { 378 | $.each($.DirtyForms.helpers, function (i, helper) { 379 | if (helper[method]) { helper[method]($node, index, excludeIgnored); } 380 | }); 381 | } 382 | }); 383 | }; 384 | 385 | var getFieldValue = function ($field) { 386 | var value; 387 | if ($field.is('select')) { 388 | value = ''; 389 | $field.find('option').each(function () { 390 | var $option = $(this); 391 | if ($option.is(':selected')) { 392 | if (value.length > 0) { value += ','; } 393 | value += $option.val(); 394 | } 395 | }); 396 | } else if ($field.is(":checkbox,:radio")) { 397 | value = $field.is(':checked'); 398 | } else { 399 | value = $field.val(); 400 | } 401 | 402 | return value; 403 | }; 404 | 405 | var storeOriginalValue = function ($field) { 406 | dirtylog('Storing original value for ' + $field.attr('name')); 407 | $field.data('df-orig', getFieldValue($field)); 408 | var isEmpty = ($field.data('df-orig') === undefined); 409 | $field.data('df-empty', isEmpty); 410 | }; 411 | 412 | var hasOriginalValue = function ($field) { 413 | return ($field.data('df-orig') !== undefined || $field.data('df-empty') === true); 414 | }; 415 | 416 | var getIgnoreSelector = function () { 417 | var dirtyForms = $.DirtyForms, 418 | result = dirtyForms.ignoreSelector; 419 | $.each(dirtyForms.helpers, function (key, obj) { 420 | if ('ignoreSelector' in obj) { 421 | if (result.length > 0) { result += ','; } 422 | result += obj.ignoreSelector; 423 | } 424 | }); 425 | return result; 426 | }; 427 | 428 | var isFieldIgnored = function ($field, ignoreSelector) { 429 | if (!ignoreSelector) { 430 | ignoreSelector = getIgnoreSelector(); 431 | } 432 | return $field.is(ignoreSelector) || $field.closest('.' + $.DirtyForms.ignoreClass).length > 0; 433 | }; 434 | 435 | var isFieldDirty = function ($field, ignoreSelector) { 436 | if (!hasOriginalValue($field) || isFieldIgnored($field, ignoreSelector)) return false; 437 | return (getFieldValue($field) != $field.data('df-orig')); 438 | }; 439 | 440 | var setFieldStatus = function ($field, ignoreSelector) { 441 | if (isFieldIgnored($field, ignoreSelector)) return; 442 | 443 | // Option groups are a special case because they change more than the current element. 444 | if ($field.is(':radio[name]')) { 445 | var name = $field.attr('name'), 446 | $form = $field.parents('form'); 447 | 448 | $form.find(":radio[name='" + name + "']").each(function () { 449 | var $radio = $(this); 450 | setDirtyStatus($radio, isFieldDirty($radio, ignoreSelector)); 451 | }); 452 | } else { 453 | setDirtyStatus($field, isFieldDirty($field, ignoreSelector)); 454 | } 455 | }; 456 | 457 | var setDirtyStatus = function ($field, isDirty) { 458 | dirtylog('Setting dirty status to ' + isDirty + ' on field ' + $field.attr('id')); 459 | var dirtyClass = $.DirtyForms.dirtyClass, 460 | $form = $field.parents('form'); 461 | 462 | // Mark the field dirty/clean 463 | $field.toggleClass(dirtyClass, isDirty); 464 | var changed = (isDirty !== ($form.hasClass(dirtyClass) && $form.find(':dirty').length === 0)); 465 | 466 | if (changed) { 467 | dirtylog('Setting dirty status to ' + isDirty + ' on form ' + $form.attr('id')); 468 | $form.toggleClass(dirtyClass, isDirty); 469 | 470 | if (isDirty) $form.trigger('dirty.dirtyforms'); 471 | if (!isDirty) $form.trigger('clean.dirtyforms'); 472 | } 473 | }; 474 | 475 | // A delay to keep the key events from slowing down when changing the dirty status on the fly. 476 | var delay = (function () { 477 | var timer = 0; 478 | return function (callback, ms) { 479 | clearTimeout(timer); 480 | timer = setTimeout(callback, ms); 481 | }; 482 | })(); 483 | 484 | var bindFn = function (ev) { 485 | var $element = $(ev.target), 486 | eventType = ev.type, 487 | dirtyForms = $.DirtyForms; 488 | dirtylog('Entering: Leaving Event fired, type: ' + eventType + ', element: ' + ev.target + ', class: ' + $element.attr('class') + ' and id: ' + ev.target.id); 489 | 490 | // Important: Do this check before calling events.clearUnload() 491 | if (ev.isDefaultPrevented()) { 492 | dirtylog('Leaving: Event has been stopped elsewhere'); 493 | return false; 494 | } 495 | 496 | if (eventType == 'beforeunload' && state.doubleunloadfix) { 497 | dirtylog('Skip this unload, Firefox bug triggers the unload event multiple times'); 498 | state.doubleunloadfix = false; 499 | return false; 500 | } 501 | 502 | if ($element.is(':dirtyignored')) { 503 | dirtylog('Leaving: Element has ignore class or a descendant of an ignored element'); 504 | events.clearUnload(); 505 | return false; 506 | } 507 | 508 | if (state.deciding) { 509 | dirtylog('Leaving: Already in the deciding process'); 510 | return false; 511 | } 512 | 513 | if (!$('form:dirtylistening').dirtyForms('isDirty')) { 514 | dirtylog('Leaving: Not dirty'); 515 | events.clearUnload(); 516 | return false; 517 | } 518 | 519 | if (eventType == 'submit' && $element.dirtyForms('isDirty')) { 520 | dirtylog('Leaving: Form submitted is a dirty form'); 521 | events.clearUnload(); 522 | return true; 523 | } 524 | 525 | // Callback for page access in current state 526 | $(document).trigger('defer.dirtyforms'); 527 | 528 | if (eventType == 'beforeunload') { 529 | dirtylog('Returning to beforeunload browser handler with: ' + dirtyForms.message); 530 | return dirtyForms.message; 531 | } 532 | if (!dirtyForms.dialog) return; 533 | 534 | // Using the GUI dialog... 535 | ev.preventDefault(); 536 | ev.stopImmediatePropagation(); 537 | 538 | dirtylog('Setting deciding active'); 539 | state.deciding = true; 540 | state.decidingEvent = ev; 541 | 542 | // Stash the dialog (with a form). This is done so it can be shown again via unstash(). 543 | if ($.isFunction(dirtyForms.dialog.stash)) { 544 | dirtylog('Stashing dialog content'); 545 | state.dialogStash = dirtyForms.dialog.stash(); 546 | dirtylog('Dialog Stash: ' + state.dialogStash); 547 | } 548 | 549 | // Stash the form from the dialog. This is done so we can fire events on it if the user makes a proceed choice. 550 | var stashSelector = dirtyForms.dialog.stashSelector; 551 | if (typeof stashSelector === 'string' && $element.is('form') && $element.parents(stashSelector).length > 0) { 552 | dirtylog('Stashing form'); 553 | state.formStash = $element.clone(true).hide(); 554 | } else { 555 | state.formStash = false; 556 | } 557 | 558 | dirtylog('Deferring to the dialog'); 559 | 560 | // Create a new choice object 561 | choice = { 562 | proceed: false, 563 | commit: function (ev) { 564 | return doCommit(ev, choice.proceed); 565 | }, 566 | bindEscKey: true, 567 | bindEnterKey: false, 568 | proceedSelector: '', 569 | staySelector: '' 570 | }; 571 | 572 | dirtyForms.dialog.open(choice, dirtyForms.message, dirtyForms.ignoreClass); 573 | bindDialog(choice); 574 | }; 575 | 576 | var refire = function (ev) { 577 | if (ev.type === 'click') { 578 | dirtylog("Refiring click event"); 579 | events.onRefireClick(ev); 580 | } else { 581 | dirtylog("Refiring " + ev.type + " event on " + ev.target); 582 | var target; 583 | if (state.formStash) { 584 | dirtylog('Appending stashed form to body'); 585 | target = state.formStash; 586 | $('body').append(target); 587 | } 588 | else { 589 | target = $(ev.target).closest('form'); 590 | } 591 | target.trigger(ev.type); 592 | } 593 | }; 594 | 595 | /**/ 596 | var dirtylog = function (msg) { 597 | if (!$.DirtyForms.debug) return; 598 | var hasFirebug = 'console' in window && 'firebug' in window.console, 599 | hasConsoleLog = 'console' in window && 'log' in window.console; 600 | msg = '[DirtyForms] ' + msg; 601 | if (hasFirebug) { 602 | console.log(msg); 603 | } else if (hasConsoleLog) { 604 | window.console.log(msg); 605 | } else { 606 | alert(msg); 607 | } 608 | }; 609 | /**/ 610 | 611 | /**/ 612 | })); 613 | /**/ 614 | --------------------------------------------------------------------------------