Skip to content

Commit 541f801

Browse files
author
Tom Kaczocha
committed
First working version.
1 parent 848c6b5 commit 541f801

6 files changed

Lines changed: 117 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
bower_components

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
Bootstrap confirm delete modal dialog jquery plugin
44

5+
## Examples

bootstrap-confirm-delete.css

Whitespace-only changes.

bootstrap-confirm-delete.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Created by Tom on 9/07/2015.
3+
*/
4+
5+
( function ( $ )
6+
{
7+
$.fn.bootstrap_confirm_delete = function ( options )
8+
{
9+
$( this ).on( 'click', function ( event )
10+
{
11+
event.preventDefault();
12+
13+
var heading = 'Delete';
14+
var message = 'Are you sure you want to delete this item?';
15+
16+
if ( undefined !== options )
17+
{
18+
if ( undefined !== options.heading )
19+
{
20+
heading = options.heading;
21+
}
22+
23+
if ( undefined !== options.question )
24+
{
25+
message = options.question;
26+
}
27+
}
28+
else
29+
{
30+
if ( undefined !== $( this ).attr( 'data-type' ) )
31+
{
32+
var name = $( this ).attr( 'data-type' );
33+
34+
heading = 'Delete ' + name[ 0 ].toUpperCase() + name.substr( 1 );
35+
message = 'Are you sure you want to delete this ' + name + '?';
36+
}
37+
}
38+
39+
if ( null === document.getElementById( 'bootstrap-confirm-delete-container' ) )
40+
{
41+
$( 'body' ).append( '<div id="bootstrap-confirm-delete-container"><div id="bootstrap-confirm-dialog" class="modal fade"><div class="modal-dialog modal-sm"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button><h4 id="bootstrap-confirm-dialog-heading"></h4></div><div class="modal-body"><p id="bootstrap-confirm-dialog-text"></p></div><div class="modal-footer"><button id="bootstrap-confirm-dialog-cancel-delete-btn" type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button><a id="bootstrap-confirm-dialog-delete-btn" href="#" class="btn btn-danger pull-right">Delete</a></div></div></div></div></div>' );
42+
}
43+
44+
$( '#bootstrap-confirm-dialog-heading' ).html( heading );
45+
$( '#bootstrap-confirm-dialog-text' ).html( message );
46+
$( '#bootstrap-confirm-dialog' ).modal( 'toggle' );
47+
$( 'a#bootstrap-confirm-dialog-delete-btn' ).attr( 'href', event.currentTarget.href );
48+
} );
49+
};
50+
}( jQuery ) );

bower.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "bootstrap-confirm-delete",
3+
"version": "1.0.0",
4+
"homepage": "https://github.com/rawphp/Bootstrap-Confirm-Delete",
5+
"authors": [
6+
"Tom Kaczocha <tom@rawphp.org>"
7+
],
8+
"description": "Bootstrap confirm delete modal dialog jquery plugin",
9+
"main": "bootstrap-confirm-delete.js, bootstrap-confirm-delete.css",
10+
"keywords": [
11+
"bootstrap",
12+
"confirm",
13+
"delete",
14+
"modal",
15+
"extension",
16+
"plugin"
17+
],
18+
"license": "MIT",
19+
"ignore": [
20+
"**/.*",
21+
"node_modules",
22+
"bower_components",
23+
"test",
24+
"tests"
25+
],
26+
"dependencies": {
27+
"jquery": ">= 1.9.1",
28+
"bootstrap": ">= 3.3.5"
29+
},
30+
"moduleType": [
31+
"globals"
32+
]
33+
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "bootstrap-confirm-delete",
3+
"version": "1.0.0",
4+
"description": "Bootstrap confirm delete modal dialog jquery plugin",
5+
"main": "bootstrap-confirm-dialog.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/rawphp/Bootstrap-Confirm-Delete.git"
12+
},
13+
"keywords": [
14+
"bootstrap",
15+
"confirm",
16+
"delete",
17+
"modal",
18+
"extension",
19+
"plugin"
20+
],
21+
"author": "Tom Kaczocha <tom@crazydev.org>",
22+
"license": "GPL-2.0",
23+
"bugs": {
24+
"url": "https://github.com/rawphp/Bootstrap-Confirm-Delete/issues"
25+
},
26+
"homepage": "https://github.com/rawphp/Bootstrap-Confirm-Delete",
27+
"dependencies": {
28+
"jquery": ">= 1.9.1",
29+
"bootstrap": ">= 3.3.5"
30+
}
31+
}

0 commit comments

Comments
 (0)