forked from joaool/MotherGithub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bootstrap_modal1.html
360 lines (351 loc) · 18.4 KB
/
test_bootstrap_modal1.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test bootstrap modal v1.0</title>
<script src="FL_ui/js/jquery-1.11.1.js" type="text/javascript"></script>
<script src="FL_ui/js/underscore-min.js"></script>
<script src="FL_ui/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="FL_ui/css/FLcerulean.css">
<!--[if lt IE 9]>
<script src="//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<style>
.modal-header-success {
color:#fff;
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #5cb85c;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.modal-header-warning {
color:#fff;
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #f0ad4e;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.modal-header-danger {
color:#fff;
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #d9534f;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.modal-header-info {
color:#fff;
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #5bc0de;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.modal-header-primary {
color:#fff;
padding:9px 15px;
border-bottom:1px solid #eee;
background-color: #428bca;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
</style>
<body>
<div id="_modalDialog"></div>
<div id="_modalDialogA"></div>
<div id="_modalDialogB"></div>
<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>
<a data-toggle="modal" href="#__FLmodalId_A" class="btn btn-primary">Launch modal A</a>
<a data-toggle="modal" href="#__FLmodalId_B" class="btn btn-primary">Launch modal B</a>
<footer class="footer">
<div class="container">
<p>©2014 FrameLink Co. <a href="http://www.framelink.co/contacts.html" target="">@support</a>.</p>
</div>
</footer>
<script id="dictTemplate" type="text/template">
<div class="dictTemplate" style="margin-top:0px;">
<form>
<div class="row">
<div class="col-xs-12" >
<div class="form-group">
<label class="control-label" for="_dictTemplate_singular">Please give a name common to every single line...</label>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Each line is a single:</span>
<input type="text" class="form-control" id="_dictTemplate_singular" name="singular" placeholder="Ex. client, supplier, member, partner..." onkeyup="FL.slidePanels.dictTemplateChangeWhatIsLabel(this.form)">
</div>
<label class="control-label" for="_dictTemplate_singularDescription" id="_dictTemplate_whatIsLabel" >What is a </label>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Description:</span>
<textarea class="form-control" id="_dictTemplate_singularDescription" name="description" onkeyup="FL.slidePanels.dictTemplateChangeDescription(this.form)" rows="3"></textarea>
</div>
<div>
<h4 id="_dictTemplate_plural">*</h4>
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 1:</span>
<input type="text" class="form-control" id="_dictTemplate_field1" name="field1">
</div>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Attribute</th>
<th>what is it ?</th>
<th>Statement to validate</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>
<input type="text" class="form-control" id="_dictTemplate_field1" name="field1" value="address">
</td>
<td>
<input type="text" class="form-control" id="_dictTemplate_field1" name="field1" value="the address to send invoices">
</td>
<td>the address of Client is the address to send invoices</td>
</tr>
<tr>
<td>2</td>
<td>Peter</td>
<td>Parker</td>
<td>the Peter of Client is the Parker</td>
</tr>
<tr>
<td>3</td>
<td>John</td>
<td>Rambo</td>
<td>the John of Client is the Rambo</td>
</tr>
</tbody>
</table>
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 2:</span>
<input type="text" class="form-control" id="_dictTemplate_field2" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 3:</span>
<input type="text" class="form-control" id="_dictTemplate_field3" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 4:</span>
<input type="text" class="form-control" id="_dictTemplate_field4" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 5:</span>
<input type="text" class="form-control" id="_dictTemplate_field5" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 6:</span>
<input type="text" class="form-control" id="_dictTemplate_field6" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 7:</span>
<input type="text" class="form-control" id="_dictTemplate_field7" name="field1">
</div>
<div class="input-group" style="line-height:0px;">
<span class="input-group-addon">Field 8:</span>
<input type="text" class="form-control" id="_dictTemplate_field8" name="field1">
</div>
</div>
</div>
</div>
</form>
</div>
</script>
<script id="loginTemplate" type="text/template">
<div class="loginExample" style="margin-top:0px;">
<form>
<div class="row">
<div class="col-xs-12" >
<div class="input-group" style="line-height:0px;">
<input type="email" class="form-control" id="inputEmail" placeholder="Email Address" >
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
</div>
<div class="input-group" style="line-height:0px;">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
</div>
<button type="submit" class="btn btn-primary" onclick="loginFunction()">Login</button>
</div>
</div>
</form>
</div>
</script>
<script>
console.log("Begin !");
var loginFunction = function(){
console.log("loginFunction !!!");
}
// makeModal("A","Patolinas","dictTemplate",{},function(result){// "Cancel and "Ok" will be assumed with result = true for "Ok"
// if(result){
// alert("Yup in Patolinas");
// }else{
// alert("Nope in Patolinas");
// }
// });//OK
makeModal("B"," Mastruncex","loginTemplate",{icon:"user"},function(result){// "Cancel and "Ok" will be assumed with result = true for "Ok"
console.log("inside Callback....");
if(result){
console.log("Yup in Mastrunço");
}else{
console.log("Nope in Mastrunço");
}
});//OK
// makeModal(" Juakim","dictTemplate",{type:"primary", icon:"search",button1:"Close",button2:"Save Changes"});//OK
// makeModal(" Juakim","dictTemplate",{type:"primary", icon:"search",button1:"Close",button2:"Save Changes"},function(result){
// if(result){
// alert("Yup");
// }else{
// alert("Nope");
// }
// });//OK
// // makeModalInfo("I want banana");//OK
// makeModalConfirm("Do I want to continue","No","Yes Please",function(result){
// if(result){
// // alert("Yup");
// makeModalInfo("Good to know that you want to continue !!!");
// }else{
// // alert("Nope");
// makeModalInfo("Bad News !!! you wanna go...");
// }
// });//OK
// makeModal(" Juakim","dictTemplate");//OK
// makeModal("Saying Hello","<p>Hello world !!!</p>");//OK
function makeModalInfo(message) {
makeModal("","Information","<p>"+message+"</p>",{type:"primary",button1:"Ok",button2:null});//OK
};
function makeModalConfirm(message,btn1,btn2,makeModalConfirmCB) {
makeModal("","Confirmation","<p>"+message+"</p>",{type:"primary",button1:btn1,button2:btn2},makeModalConfirmCB);//OK
};
function makeModal(id,title,templateName,options,makeModalCB) {
// CONDITIONS NECESSARY FOR makeModal() to work:
// 1 - THE BODY MUST HAVE A DEDICATED SLOT: <div id="_modalDialog"+{id}></div>
// title - Model window title
// type - success, primary, info, warning and danger
// templateName - normally is a html template defined with <script id="templateName" type="text/template">
// it can be a direct html string if first char is "<".
// options - JSON with icon and type
// icon - termination of http://getbootstrap.com/components/ -
// ex: glyphicon glyphicon-thumbs-up =>"thumbs-up"
// glyphicon glyphicon-search =>"search"
// glyphicon glyphicon-ok =>"ok" etc...
// type - success, primary, info, warning and danger
// button1 - name of first button
// button2 - name of second button (null =>only one button is available)
// callback - to return result example:
// makeModal(" Juakim","dictTemplate",{type:"primary", icon:"search",button1:"Close",button2:"Save Changes"},function(result){
// if(result){
// alert("Yup");
// }else{
// alert("Nope");
// }
// });
// NOTE: Callback argument result = true if button 2 is pressed, result = false if button 1 is pressed
// http://www.sitepoint.com/understanding-bootstrap-modals/
var options = _.extend( {icon:null,type:"success",button1:"Cancel",button2:"Ok"},options);
var modalId = "__FLmodalId_"+id;
var htmlIn = null;
console.log("Inside:"+templateName.substring(0,0));
if( templateName.substring(0,1) == "<"){
htmlIn = templateName;
}else{
var templateFunc = _.template($("#" + templateName ).html());
var htmlIn = templateFunc({name:"Joao",age:58,occupation:"tangas"});
}
var iconHTML = "";
if(options.icon){
iconHTML = '<i class="glyphicon glyphicon-' + options.icon +'"></i>';
}
var button1HTML = "";
if(options.button1){
button1HTML = '<a href="#" id="__FLDialog_button1" data-dismiss="modal" class="btn">' + options.button1 + '</a>';
}
var button2HTML = "";
if(options.button2){
button2HTML = '<a href="#" id="__FLDialog_button2" class="btn btn-' + options.type + '">' + options.button2 + '</a>';
}
// var before = '<div class="modal fade" id="myModal">' +
var before = '<div class="modal fade" id="' +modalId+ '">' +
'<div class="modal-dialog">' +
'<div class="modal-content">' +
'<div class="modal-header modal-header-' + options.type + '">' +
'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'+
// '<h3 style="color:white;" class="modal-title">' + title + '</h3>' +
// '<h3 style="color:white;" class="modal-title"><i class="glyphicon glyphicon-thumbs-up"></i>' + title + '</h3>' +
'<h3 style="color:white;" class="modal-title">' + iconHTML + title + '</h3>' +
'</div>' +
'<div class="modal-body">';
var after = '</div>' +
'<div class="modal-footer">' +
// '<a href="#button1" id="__FLDialog_button1" data-dismiss="modal" class="btn">Close</a>' +
button1HTML +
// '<a href="#button2" id="__FLDialog_button2" class="btn btn-primary">Save changes</a>' +
button2HTML +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
var fullHTML = before + htmlIn + after;
console.log("makeModal="+fullHTML);
var $modalDialog = $("#_modalDialog"+id);
$modalDialog.empty();// "#_modalDialog" is the DOM reserved slot for dialog boxes
$modalDialog.html(fullHTML);
var $modal = $('#' + modalId );
console.log("after jquery...");
if(makeModalCB){
$modal.on("click","#__FLDialog_button1", function() {
console.log("makeModal - You clicked button1");
$modal.off('hidden.bs.modal');
$modal.modal('hide');
return makeModalCB(false);
});
$modal.on("click","#__FLDialog_button2", function() {
console.log("makeModal - You clicked button2");
$modal.off('hidden.bs.modal');
$modal.modal('hide');
return makeModalCB(true);
});
$modal.on('hidden.bs.modal', function() {
// alert("makeModal - You closed the window !!!");
return makeModalCB(false);
});
}else{
// $modal.off('hidden.bs.modal');
$modal.modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
}
// $('#' + modalId ).modal('show');//to launch it immediatly when calling makeModal
$modal.modal('show');//to launch it immediatly when calling makeModal
};
</script>
</body>
</html>