@@ -3,275 +3,16 @@ Bootstrap modal wrapper factory for creating dynamic and nested stacked dialog f
33
44## Installation Using NPM
55```
6- npm install bootstrap-modal-wrapper
6+ npm install bootstrap-actionable
77```
88
99## Building from The source
1010Make sure node.js and git client are locally installed on your machine and then run the following commands:
1111```
12- cd bootstrap-modal-wrapper
12+ cd bootstrap-actionable
1313npm install
1414gulp
1515```
16- ## Demo And Examples
17- Online demo of all below examples can be found in the following JavaTMP demo page [ Bootstrap Modal Online Demo] ( http://demo.javatmp.com/JavaTMP-Static-Ajax/#pages/bootstrap/modal.html ) .
18-
19- ### BOOTSTRAP MESSAGE MODAL
20- The simplest scenario of modal wrapper is to show a simple message when use press a button:
21- ``` html
22- <button id =" simple-message" type =" button" class =" btn btn-primary" >
23- Basic Message
24- </button >
25- <script type =" text/javascript" >
26- jQuery (function ($ ) {
27- $ (" #simple-message" ).on (" click" , function (event ) {
28- BootstrapModalWrapperFactory .showMessage (" Delfault Message to show to user" );
29- });
30- });
31- </script >
32- ```
33-
34- ### BOOTSTRAP ALERT MODAL
35- The simple scenario of modal wrapper is to show a simple alert when use press a button:
36- ``` html
37- <button id =" simple-alert" type =" button" class =" btn btn-primary" >
38- Basic Alert
39- </button >
40- <script type =" text/javascript" >
41- jQuery (function ($ ) {
42- $ (" #simple-alert" ).on (" click" , function (event ) {
43- BootstrapModalWrapperFactory .alert (" Delfault alert <b>with only message Text</b>" );
44- });
45- });
46- </script >
47- ```
48-
49- ### BOOTSTRAP CONFIRMATION MODAL
50- JavaTMP Bootstrap modal wrapper factory provides a confirmation dialog too with ability to run different code. See the following example:
51- ``` html
52- <button id =" simple-confirm" type =" button" class =" btn btn-primary" >
53- Basic Confirm
54- </button >
55- <script type =" text/javascript" >
56- jQuery (function ($ ) {
57- $ (" #simple-confirm" ).on (" click" , function (event ) {
58- BootstrapModalWrapperFactory .confirm ({
59- title: " Confirm" ,
60- message: " Are You Sure ?" ,
61- onConfirmAccept : function () {
62- BootstrapModalWrapperFactory .alert (" Thank you for ACCEPTING the previous confiramtion dialog" );
63- },
64- onConfirmCancel : function () {
65- BootstrapModalWrapperFactory .alert (" Thank you for CANCELING the previous confiramtion dialog" );
66- }
67- });
68- });
69- });
70- </script >
71- ```
72- ### JAVATMP BOOTSTRAP MODAL WRAPPER ` CREATEMODAL ` METHOD
73- The JavaTMP Bootstrap Modal wrapper object provides a general method ` createModal ` which creates modals dynamically.
74- the implementation of ` BootstrapModalWrapperFactory.alert ` and ` BootstrapModalWrapperFactory.confirm ` methods use ` createModal `
75- to provide desired behaviors.
76- The following examples show you how to use ` createModal ` method in action:
77- #### Create simple Bootstrap Modal wrapper instance dynamically
78- ``` JS
79- var onlyBody = BootstrapModalWrapperFactory .createModal ({
80- message: " Simple Message body" ,
81- closable: false ,
82- closeByBackdrop: true
83- });
84- onlyBody .show ();
85- ```
86- #### Create a simple bootstrap modal wrapper with body and title only:
87- ``` JS
88- var modalWrapper = BootstrapModalWrapperFactory .createModal ({
89- message: " Simple Message body" ,
90- title: " Header Title" ,
91- closable: true ,
92- closeByBackdrop: true
93- });
94- modalWrapper .show ();
95- ```
96- #### Create a simple bootstrap modal wrapper with a button to close and destroy it
97- ``` JS
98- var modalWrapper = BootstrapModalWrapperFactory .createModal ({
99- message: " Simple Message body" ,
100- title: " Header Title" ,
101- closable: false ,
102- closeByBackdrop: false ,
103- buttons: [
104- {
105- label: " Close Me" ,
106- cssClass: " btn btn-primary" ,
107- action : function (modalWrapper , button , buttonData , originalEvent ) {
108- return modalWrapper .hide ();
109- }
110- }
111- ]
112- });
113- modalWrapper .show ();
114- ```
115- #### Create nested bootstrap modal wrapper instances dynamically:
116- ``` JS
117- var modalWrapper = BootstrapModalWrapperFactory .createModal ({
118- message: " Simple Message body" ,
119- title: " Header Title" ,
120- closable: false ,
121- closeByBackdrop: false ,
122- buttons: [
123- {
124- label: " Close" ,
125- cssClass: " btn btn-secondary" ,
126- action : function (modalWrapper , button , buttonData , originalEvent ) {
127- return modalWrapper .hide ();
128- }
129- },
130- {
131- label: " Create alert" ,
132- cssClass: " btn btn-primary" ,
133- action : function (modalWrapper , button , buttonData , originalEvent ) {
134- BootstrapModalWrapperFactory .alert (" Alert Modal Created" );
135- }
136- }
137- ]
138- }).show ();
139- ```
140- #### Update title and body of bootstrap modal wrapper dynamically after showing:
141- ``` JS
142- BootstrapModalWrapperFactory .createModal ({
143- message: " Simple Message body" ,
144- title: " Header Title" ,
145- closable: false ,
146- closeByBackdrop: false ,
147- buttons: [
148- {
149- label: " Close" ,
150- cssClass: " btn btn-secondary" ,
151- action : function (modalWrapper , button , buttonData , originalEvent ) {
152- return modalWrapper .hide ();
153- }
154- },
155- {
156- label: " Update Title & Message" ,
157- cssClass: " btn btn-primary" ,
158- action : function (modalWrapper , button , buttonData , originalEvent ) {
159- modalWrapper .updateTitle (" New Title" );
160- modalWrapper .updateMessage (" Updated message content" );
161- }
162- }
163- ]
164- }).show ();
165- ```
166- #### Update the size of shown bootstrap modal dynamically:
167- ``` JS
168- BootstrapModalWrapperFactory .createModal ({
169- message: " Simple Message body" ,
170- title: " Header Title" ,
171- closable: false ,
172- closeByBackdrop: false ,
173- buttons: [
174- {
175- label: " Close" ,
176- cssClass: " btn btn-secondary" ,
177- action : function (modalWrapper , button , buttonData , originalEvent ) {
178- return modalWrapper .hide ();
179- }
180- },
181- {
182- label: " Make Me Large" ,
183- cssClass: " btn btn-primary" ,
184- action : function (modalWrapper , button , buttonData , originalEvent ) {
185- modalWrapper .originalModal .find (" .modal-dialog" ).css ({transition: ' all 0.4s' });
186- modalWrapper .updateSize (" modal-lg" );
187- }
188- },
189- {
190- label: " Make Me Small" ,
191- cssClass: " btn btn-primary" ,
192- action : function (modalWrapper , button , buttonData , originalEvent ) {
193- modalWrapper .originalModal .find (" .modal-dialog" ).css ({transition: ' all 0.4s' });
194- modalWrapper .updateSize (" modal-sm" );
195- }
196- },
197- {
198- label: " Make Me Default" ,
199- cssClass: " btn btn-primary" ,
200- action : function (modalWrapper , button , buttonData , originalEvent ) {
201- modalWrapper .originalModal .find (" .modal-dialog" ).css ({transition: ' all 0.4s' });
202- modalWrapper .updateSize (null );
203- }
204- }
205- ]
206- }).show ();
207- ```
208- #### Create Bootstrap Modal wrapper buttons dynamically and remove them:
209- ``` JS
210- var buttonsCount = 0 ;
211- BootstrapModalWrapperFactory .createModal ({
212- message: " Simple Message body" ,
213- title: " Header Title" ,
214- closable: false ,
215- closeByBackdrop: false ,
216- buttons: [
217- {
218- label: " Close" ,
219- cssClass: " btn btn-secondary" ,
220- action : function (modalWrapper , button , buttonData , originalEvent ) {
221- return modalWrapper .hide ();
222- }
223- },
224- {
225- label: " Add Button" ,
226- cssClass: " btn btn-primary" ,
227- action : function (modalWrapper , button , buttonData , originalEvent ) {
228- modalWrapper .addButton ({
229- id: " id-" + (++ buttonsCount),
230- label: " New " + buttonsCount,
231- cssClass: " btn btn-secondary" ,
232- action : function (modalWrapper , button , buttonData , originalEvent ) {
233- BootstrapModalWrapperFactory .showMessage (" nothing only to show attached event to button id [" + buttonData .id + " ]" );
234- return true ;
235- }
236- }, true );
237- }
238- },
239- {
240- label: " Delete Button" ,
241- cssClass: " btn btn-primary" ,
242- action : function (modalWrapper , button , buttonData , originalEvent ) {
243- modalWrapper .removeButton (" id-" + (buttonsCount-- ));
244- }
245- }
246- ]
247- }).show ();
248- ```
249- #### Simulate Updating Bootstrap Modal wrapper instace dynamically with AJAX response content:
250- ``` JS
251- var m = BootstrapModalWrapperFactory .createModal ({
252- message: ' <div class="text-center"><i class="fa fa-refresh fa-spin fa-3x fa-fw text-primary"></i></div>' ,
253- closable: false ,
254- closeByBackdrop: false
255- });
256- m .originalModal .find (" .modal-dialog" ).css ({transition: ' all 0.5s' });
257- m .show ();
258- setTimeout (function () {
259- m .updateSize (" modal-lg" );
260- m .updateTitle (" Message Received" );
261- m .updateMessage (" Message Content" );
262- m .addButton ({
263- label: " Close" ,
264- cssClass: " btn btn-secondary" ,
265- action : function (modalWrapper , button , buttonData , originalEvent ) {
266- return modalWrapper .hide ();
267- }
268- }, true );
269- }, 3000 );
270- ```
271- #### Advanced AJAX Bootstrap Modal Wrapper Contents
272- You can simply adapt and use the bootstrap modal wrapper to provide a dynamic Bootstrap modal with remote AJAX contents,
273- for example see [ the navbar's message tab items in JavaTMP Demo Home Page] ( http://demo.javatmp.com/JavaTMP-Static-Ajax/#pages/home.html ) .
274- The following online documentation code provides you with the starting point to implement them https://www.javatmp.com/pages/javatmp-actionable-plugin .
27516
27617## Copyright and License
27718Bootstrap-modal-wrapper is copyrighted by [ JavaTMP] ( http://www.javatmp.com ) and licensed under [ MIT license] ( https://github.com/JavaTMP/bootstrap-modal-wrapper/blob/master/LICENSE ) .
0 commit comments