-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootbox_dialog_manager.js
66 lines (60 loc) · 1.44 KB
/
bootbox_dialog_manager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*!
* Bootbox Dialog Manager.js to easely control multiple Bootbox at one time.
*
* @version 1.0.0
* @license MIT
* @site https://github.com/AcTiv3MineD/Bootbox-Dialog-Manager
* @author Augusto Vargas <[email protected]>
*/
var dialog_manager = {
dialogs: [ ],
/**
* Add/register a new bootbox element.
*
* @param id {string} The id of the bootbox element
* @param dialog {bootbox} The bootbox element
*
* @return void
*/
add: function ( id, dialog ) {
this.dialogs[ id ] = dialog;
},
/**
* Remove all registered elements.
*
* @return void
*/
remove_all: function ( ) {
for ( var i = dialogs.length - 1; i >= 0; i-- ) {
this.dialogs[ i ].modal( 'hide' );
}
this.dialogs = [ ];
$( '.modal-backdrop' ).remove( );
},
/**
* Remove a given registered element.
*
* @param id {string} The id of the bootbox element
*
* @return void
*/
remove: function( id ){
if( this.dialogs[ id ] == undefined ) return;
this.dialogs[ id ].modal( 'hide' );
delete this.dialogs[ id ];
if( this.dialogs.length == 0 ){
$( '.modal-backdrop' ).remove( );
}
},
/**
* Get a given registered element.
*
* @param id {string} The id of the bootbox element
*
* @return {bootbox object} if not found null is returned
*/
get: function( id ){
if( this.dialogs[ id ] == undefined ) return null;
return this.dialogs[ id ];
}
};