582
+ − 1
// Message box and visual effect system
+ − 2
+ − 3
/**
+ − 4
* The ultimate message box framework for Javascript
+ − 5
* Syntax is (almost) identical to the MessageBox command in NSIS
+ − 6
* @param int type - a bitfield consisting of the MB_* constants
+ − 7
* @param string title - the blue text at the top of the window
+ − 8
* @param string text - HTML for the body of the message box
+ − 9
* Properties:
+ − 10
* onclick - an array of functions to be called on button click events
+ − 11
* NOTE: key names are to be strings, and they must be the value of the input, CaSe-SeNsItIvE
+ − 12
* onbeforeclick - same as onclick but called before the messagebox div is destroyed
+ − 13
* Methods:
+ − 14
* destroy: kills the running message box
+ − 15
* Example:
+ − 16
* var my_message = new MessageBox(MB_OK|MB_ICONSTOP, 'Error logging in', 'The username and/or password is incorrect. Please check the username and retype your password');
+ − 17
* my_message.onclick['OK'] = function() {
+ − 18
* document.getElementById('password').value = '';
+ − 19
* };
+ − 20
* Deps:
+ − 21
* Modern browser that supports DOM
+ − 22
* darken() and enlighten() (above)
+ − 23
* opacity() - required for darken() and enlighten()
+ − 24
* MB_* constants are defined in enano-lib-basic.js
+ − 25
*/
+ − 26
+ − 27
var mb_current_obj;
+ − 28
var mb_previously_had_darkener = false;
+ − 29
+ − 30
function MessageBox(type, title, message)
+ − 31
{
+ − 32
if ( !aclDisableTransitionFX )
+ − 33
{
+ − 34
load_component('flyin');
+ − 35
}
+ − 36
+ − 37
var y = getScrollOffset();
+ − 38
+ − 39
// Prevent multiple instances
+ − 40
if ( document.getElementById('messageBox') )
+ − 41
return;
+ − 42
+ − 43
if ( document.getElementById('specialLayer_darkener') )
+ − 44
if ( document.getElementById('specialLayer_darkener').style.display == 'block' )
+ − 45
mb_previously_had_darkener = true;
+ − 46
if ( !mb_previously_had_darkener )
+ − 47
darken(true);
+ − 48
if ( aclDisableTransitionFX )
+ − 49
{
+ − 50
document.getElementById('specialLayer_darkener').style.zIndex = '5';
+ − 51
}
+ − 52
var master_div = document.createElement('div');
694
43367c66d869
Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
diff
changeset
+ − 53
master_div.style.zIndex = getHighestZ() + 1;
582
+ − 54
var mydiv = document.createElement('div');
+ − 55
mydiv.style.height = '200px';
+ − 56
w = getWidth();
+ − 57
h = getHeight();
+ − 58
if ( aclDisableTransitionFX )
+ − 59
{
+ − 60
master_div.style.left = ((w / 2) - 200)+'px';
+ − 61
master_div.style.top = ((h / 2) + y - 120)+'px';
+ − 62
master_div.style.position = 'absolute';
+ − 63
}
+ − 64
else
+ − 65
{
+ − 66
master_div.style.top = '-10000px';
+ − 67
master_div.style.position = ( IE ) ? 'absolute' : 'fixed';
+ − 68
}
+ − 69
z = ( aclDisableTransitionFX ) ? document.getElementById('specialLayer_darkener').style.zIndex : getHighestZ();
+ − 70
mydiv.style.backgroundColor = '#FFFFFF';
+ − 71
mydiv.style.padding = '10px';
+ − 72
mydiv.style.marginBottom = '1px';
+ − 73
mydiv.id = 'messageBox';
+ − 74
mydiv.style.overflow = 'auto';
+ − 75
+ − 76
var buttondiv = document.createElement('div');
+ − 77
+ − 78
mydiv.style.width = '400px';
+ − 79
buttondiv.style.width = '400px';
+ − 80
+ − 81
w = getWidth();
+ − 82
h = getHeight();
+ − 83
if ( aclDisableTransitionFX )
+ − 84
{
+ − 85
//buttondiv.style.left = ((w / 2) - 200)+'px';
+ − 86
//buttondiv.style.top = ((h / 2) + y + 101)+'px';
+ − 87
}
+ − 88
//buttondiv.style.position = ( IE ) ? 'absolute' : 'fixed';
+ − 89
z = ( aclDisableTransitionFX ) ? document.getElementById('specialLayer_darkener').style.zIndex : getHighestZ();
+ − 90
buttondiv.style.backgroundColor = '#C0C0C0';
+ − 91
buttondiv.style.padding = '10px';
+ − 92
buttondiv.style.textAlign = 'right';
+ − 93
buttondiv.style.verticalAlign = 'middle';
+ − 94
buttondiv.id = 'messageBoxButtons';
+ − 95
+ − 96
this.clickHandler = function() { messagebox_click(this, mb_current_obj); };
+ − 97
+ − 98
if( ( type & MB_ICONINFORMATION || type & MB_ICONSTOP || type & MB_ICONQUESTION || type & MB_ICONEXCLAMATION ) && !(type & MB_ICONLOCK) )
+ − 99
{
+ − 100
mydiv.style.paddingLeft = '50px';
+ − 101
mydiv.style.width = '360px';
+ − 102
mydiv.style.backgroundRepeat = 'no-repeat';
+ − 103
mydiv.style.backgroundPosition = '8px 8px';
+ − 104
}
+ − 105
else if ( type & MB_ICONLOCK )
+ − 106
{
+ − 107
mydiv.style.paddingLeft = '50px';
+ − 108
mydiv.style.width = '360px';
+ − 109
mydiv.style.backgroundRepeat = 'no-repeat';
+ − 110
}
+ − 111
+ − 112
if(type & MB_ICONINFORMATION)
+ − 113
{
+ − 114
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/info.png\')';
+ − 115
}
+ − 116
+ − 117
if(type & MB_ICONQUESTION)
+ − 118
{
+ − 119
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/question.png\')';
+ − 120
}
+ − 121
+ − 122
if(type & MB_ICONSTOP)
+ − 123
{
+ − 124
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/error.png\')';
+ − 125
}
+ − 126
+ − 127
if(type & MB_ICONEXCLAMATION)
+ − 128
{
+ − 129
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/warning.png\')';
+ − 130
}
+ − 131
+ − 132
if(type & MB_ICONLOCK)
+ − 133
{
+ − 134
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/lock.png\')';
+ − 135
}
+ − 136
+ − 137
if(type & MB_OK)
+ − 138
{
+ − 139
btn = document.createElement('input');
+ − 140
btn.type = 'button';
+ − 141
btn.value = $lang.get('etc_ok');
+ − 142
btn._GenericName = 'OK';
+ − 143
btn.onclick = this.clickHandler;
+ − 144
btn.style.margin = '0 3px';
+ − 145
buttondiv.appendChild(btn);
+ − 146
}
+ − 147
+ − 148
if(type & MB_OKCANCEL)
+ − 149
{
+ − 150
btn = document.createElement('input');
+ − 151
btn.type = 'button';
+ − 152
btn.value = $lang.get('etc_ok');
+ − 153
btn._GenericName = 'OK';
+ − 154
btn.onclick = this.clickHandler;
+ − 155
btn.style.margin = '0 3px';
+ − 156
buttondiv.appendChild(btn);
+ − 157
+ − 158
btn = document.createElement('input');
+ − 159
btn.type = 'button';
+ − 160
btn.value = $lang.get('etc_cancel');
+ − 161
btn._GenericName = 'Cancel';
+ − 162
btn.onclick = this.clickHandler;
+ − 163
btn.style.margin = '0 3px';
+ − 164
buttondiv.appendChild(btn);
+ − 165
}
+ − 166
+ − 167
if(type & MB_YESNO)
+ − 168
{
+ − 169
btn = document.createElement('input');
+ − 170
btn.type = 'button';
+ − 171
btn.value = $lang.get('etc_yes');
+ − 172
btn._GenericName = 'Yes';
+ − 173
btn.onclick = this.clickHandler;
+ − 174
btn.style.margin = '0 3px';
+ − 175
buttondiv.appendChild(btn);
+ − 176
+ − 177
btn = document.createElement('input');
+ − 178
btn.type = 'button';
+ − 179
btn.value = $lang.get('etc_no');
+ − 180
btn._GenericName = 'No';
+ − 181
btn.onclick = this.clickHandler;
+ − 182
btn.style.margin = '0 3px';
+ − 183
buttondiv.appendChild(btn);
+ − 184
}
+ − 185
+ − 186
if(type & MB_YESNOCANCEL)
+ − 187
{
+ − 188
btn = document.createElement('input');
+ − 189
btn.type = 'button';
+ − 190
btn.value = $lang.get('etc_yes');
+ − 191
btn._GenericName = 'Yes';
+ − 192
btn.onclick = this.clickHandler;
+ − 193
btn.style.margin = '0 3px';
+ − 194
buttondiv.appendChild(btn);
+ − 195
+ − 196
btn = document.createElement('input');
+ − 197
btn.type = 'button';
+ − 198
btn.value = $lang.get('etc_no');
+ − 199
btn._GenericName = 'No';
+ − 200
btn.onclick = this.clickHandler;
+ − 201
btn.style.margin = '0 3px';
+ − 202
buttondiv.appendChild(btn);
+ − 203
+ − 204
btn = document.createElement('input');
+ − 205
btn.type = 'button';
+ − 206
btn.value = $lang.get('etc_cancel');
+ − 207
btn._GenericName = 'Cancel';
+ − 208
btn.onclick = this.clickHandler;
+ − 209
btn.style.margin = '0 3px';
+ − 210
buttondiv.appendChild(btn);
+ − 211
}
+ − 212
+ − 213
heading = document.createElement('h2');
+ − 214
heading.innerHTML = title;
+ − 215
heading.style.color = '#50A0D0';
+ − 216
heading.style.fontFamily = 'trebuchet ms, verdana, arial, helvetica, sans-serif';
+ − 217
heading.style.fontSize = '12pt';
+ − 218
heading.style.fontWeight = 'lighter';
+ − 219
heading.style.textTransform = 'lowercase';
+ − 220
heading.style.marginTop = '0';
+ − 221
mydiv.appendChild(heading);
+ − 222
+ − 223
var text = document.createElement('div');
+ − 224
text.innerHTML = String(message);
+ − 225
this.text_area = text;
+ − 226
mydiv.appendChild(text);
+ − 227
+ − 228
this.updateContent = function(text)
+ − 229
{
+ − 230
this.text_area.innerHTML = text;
+ − 231
};
+ − 232
+ − 233
this.destroy = function()
+ − 234
{
+ − 235
var mbdiv = document.getElementById('messageBox');
+ − 236
mbdiv.parentNode.removeChild(mbdiv.nextSibling);
+ − 237
mbdiv.parentNode.removeChild(mbdiv);
+ − 238
if ( !mb_previously_had_darkener )
+ − 239
enlighten(true);
+ − 240
};
+ − 241
+ − 242
//domObjChangeOpac(0, mydiv);
+ − 243
//domObjChangeOpac(0, master_div);
+ − 244
+ − 245
body = document.getElementsByTagName('body');
+ − 246
body = body[0];
+ − 247
master_div.appendChild(mydiv);
+ − 248
master_div.appendChild(buttondiv);
+ − 249
+ − 250
body.appendChild(master_div);
+ − 251
+ − 252
if ( !aclDisableTransitionFX )
+ − 253
setTimeout('mb_runFlyIn();', 100);
+ − 254
+ − 255
this.onclick = new Array();
+ − 256
this.onbeforeclick = new Array();
+ − 257
mb_current_obj = this;
+ − 258
}
+ − 259
+ − 260
var messagebox = MessageBox;
+ − 261
+ − 262
function mb_runFlyIn()
+ − 263
{
+ − 264
var mydiv = document.getElementById('messageBox');
+ − 265
var maindiv = mydiv.parentNode;
+ − 266
fly_in_top(maindiv, true, false);
+ − 267
}
+ − 268
+ − 269
function messagebox_click(obj, mb)
+ − 270
{
+ − 271
val = ( typeof ( obj._GenericName ) == 'string' ) ? obj._GenericName : obj.value;
+ − 272
if(typeof mb.onbeforeclick[val] == 'function')
+ − 273
{
+ − 274
var o = mb.onbeforeclick[val];
+ − 275
var resp = o();
+ − 276
if ( resp )
+ − 277
return false;
+ − 278
o = false;
+ − 279
}
+ − 280
+ − 281
var mydiv = document.getElementById('messageBox');
+ − 282
var maindiv = mydiv.parentNode;
+ − 283
+ − 284
if ( aclDisableTransitionFX )
+ − 285
{
+ − 286
var mbdiv = document.getElementById('messageBox');
+ − 287
mbdiv.parentNode.removeChild(mbdiv.nextSibling);
+ − 288
mbdiv.parentNode.removeChild(mbdiv);
+ − 289
if ( !mb_previously_had_darkener )
+ − 290
enlighten(true);
+ − 291
}
+ − 292
else
+ − 293
{
+ − 294
var to = fly_out_top(maindiv, true, false);
+ − 295
setTimeout("var mbdiv = document.getElementById('messageBox'); mbdiv.parentNode.removeChild(mbdiv.nextSibling); mbdiv.parentNode.removeChild(mbdiv); if ( !mb_previously_had_darkener ) enlighten(true);", to);
+ − 296
}
+ − 297
if(typeof mb.onclick[val] == 'function')
+ − 298
{
+ − 299
o = mb.onclick[val];
+ − 300
o();
+ − 301
o = false;
+ − 302
}
+ − 303
}
+ − 304
+ − 305
function testMessageBox()
+ − 306
{
+ − 307
mb = new MessageBox(MB_OKCANCEL|MB_ICONINFORMATION, 'Javascripted dynamic message boxes', 'This is soooooo coool, now if only document.createElement() worked in IE!<br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text');
+ − 308
mb.onclick['OK'] = function()
+ − 309
{
+ − 310
alert('You clicked OK!');
+ − 311
}
+ − 312
mb.onbeforeclick['Cancel'] = function()
+ − 313
{
+ − 314
alert('You clicked Cancel!');
+ − 315
}
+ − 316
}
+ − 317
+ − 318
/**
+ − 319
* The miniPrompt function, for creating small prompts and dialogs. The window will be flown in and the window darkened with opac=0.4.
+ − 320
* @param function Will be passed an HTMLElement that is the body of the prompt window; the function can do with this as it pleases
+ − 321
*/
+ − 322
+ − 323
function miniPrompt(call_on_create)
+ − 324
{
+ − 325
if ( !aclDisableTransitionFX )
+ − 326
{
779
609e35845ec3
load_component() now accepts an array, and most JS components are loaded all in one request now. Totally modular baby. And failsafe too.
Dan
diff
changeset
+ − 327
load_component(['flyin', 'jquery', 'jquery-ui', 'fadefilter']);
582
+ − 328
}
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 329
var darkener = darken(aclDisableTransitionFX, 40, 'miniprompt_darkener');
582
+ − 330
+ − 331
var wrapper = document.createElement('div');
+ − 332
wrapper.className = 'miniprompt';
+ − 333
var top = document.createElement('div');
+ − 334
top.className = 'mp-top';
+ − 335
var body = document.createElement('div');
+ − 336
body.className = 'mp-body';
+ − 337
var bottom = document.createElement('div');
+ − 338
bottom.className = 'mp-bottom';
+ − 339
if ( typeof(call_on_create) == 'function' )
+ − 340
{
+ − 341
call_on_create(body);
+ − 342
}
+ − 343
wrapper.appendChild(top);
+ − 344
wrapper.appendChild(body);
+ − 345
wrapper.appendChild(bottom);
+ − 346
var left = ( getWidth() / 2 ) - ( 388 / 2 );
+ − 347
wrapper.style.left = left + 'px';
+ − 348
var top = getScrollOffset() - 27;
+ − 349
wrapper.style.top = top + 'px';
+ − 350
domObjChangeOpac(0, wrapper);
+ − 351
var realbody = document.getElementsByTagName('body')[0];
+ − 352
realbody.appendChild(wrapper);
+ − 353
+ − 354
if ( aclDisableTransitionFX )
+ − 355
{
+ − 356
domObjChangeOpac(100, wrapper);
+ − 357
}
+ − 358
else
+ − 359
{
+ − 360
fly_in_top(wrapper, true, true);
+ − 361
+ − 362
setTimeout(function()
+ − 363
{
+ − 364
domObjChangeOpac(100, wrapper);
+ − 365
}, 40);
+ − 366
}
628
+ − 367
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 368
// set the darkener's onclick to refocus/shake the miniprompt
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 369
darkener.miniprompt = wrapper;
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 370
darkener.onclick = function()
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 371
{
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 372
if ( !aclDisableTransitionFX )
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 373
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 374
$(this.miniprompt).effect("pulsate", { times: 2 }, 200);
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 375
}
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 376
}
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 377
628
+ − 378
return wrapper;
582
+ − 379
}
+ − 380
+ − 381
/**
+ − 382
* For a given element, loops through the element and all of its ancestors looking for a miniPrompt div, and returns it. Returns false on failure.
+ − 383
* @param object:HTMLElement Child node to scan
+ − 384
* @return object
+ − 385
*/
+ − 386
+ − 387
function miniPromptGetParent(obj)
+ − 388
{
+ − 389
while ( true )
+ − 390
{
+ − 391
// prevent infinite loops
+ − 392
if ( !obj || obj.tagName == 'BODY' )
+ − 393
return false;
+ − 394
+ − 395
if ( $dynano(obj).hasClass('miniprompt') )
+ − 396
{
+ − 397
return obj;
+ − 398
}
+ − 399
obj = obj.parentNode;
+ − 400
}
+ − 401
return false;
+ − 402
}
+ − 403
+ − 404
/**
+ − 405
* Destroys the first miniPrompt div encountered by recursively checking all parent nodes.
+ − 406
* Usage: <a href="javascript:miniPromptDestroy(this);">click</a>
+ − 407
* @param object:HTMLElement a child of the div.miniprompt
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 408
* @param bool (DEPRECATED) If true, does not call enlighten().
582
+ − 409
*/
+ − 410
+ − 411
function miniPromptDestroy(obj, nofade)
+ − 412
{
+ − 413
obj = miniPromptGetParent(obj);
+ − 414
if ( !obj )
+ − 415
return false;
+ − 416
+ − 417
// found it
+ − 418
var parent = obj.parentNode;
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 419
// if ( !nofade )
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 420
// enlighten(aclDisableTransitionFX);
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 421
enlighten(aclDisableTransitionFX, 'miniprompt_darkener');
582
+ − 422
if ( aclDisableTransitionFX )
+ − 423
{
+ − 424
parent.removeChild(obj);
+ − 425
}
+ − 426
else
+ − 427
{
+ − 428
var timeout = fly_out_top(obj, true, true);
+ − 429
setTimeout(function()
+ − 430
{
+ − 431
parent.removeChild(obj);
+ − 432
}, timeout);
+ − 433
}
+ − 434
}
+ − 435
+ − 436
/**
+ − 437
* Simple test case
+ − 438
*/
+ − 439
+ − 440
function miniPromptTest()
+ − 441
{
+ − 442
miniPrompt(function(div) { div.innerHTML = 'hello world! <a href="#" onclick="miniPromptDestroy(this); return false;">destroy me</a>'; });
+ − 443
}
+ − 444
+ − 445
/**
+ − 446
* Message box system for miniPrompts. Less customization but easier to scale than the regular messageBox framework.
+ − 447
* @example
+ − 448
<code>
+ − 449
miniPromptMessage({
+ − 450
title: 'Delete page',
+ − 451
message: 'Do you really want to delete this page? This is reversible unless you clear the page logs.',
+ − 452
buttons: [
+ − 453
{
+ − 454
text: 'Delete',
+ − 455
color: 'red',
+ − 456
style: {
+ − 457
fontWeight: 'bold'
+ − 458
},
+ − 459
onclick: function() {
+ − 460
ajaxDeletePage();
+ − 461
miniPromptDestroy(this);
+ − 462
}
+ − 463
},
+ − 464
{
+ − 465
text: 'cancel',
+ − 466
onclick: function() {
+ − 467
miniPromptDestroy(this);
+ − 468
}
+ − 469
}
+ − 470
]
+ − 471
});
+ − 472
</code>
+ − 473
*/
+ − 474
+ − 475
function miniPromptMessage(parms)
+ − 476
{
628
+ − 477
if ( ( !parms.title && !parms.message ) || !parms.buttons )
582
+ − 478
return false;
+ − 479
+ − 480
return miniPrompt(function(parent)
+ − 481
{
+ − 482
try
+ − 483
{
628
+ − 484
if ( parms.title )
+ − 485
{
+ − 486
var h3 = document.createElement('h3');
+ − 487
h3.appendChild(document.createTextNode(parms.title));
+ − 488
}
+ − 489
if ( parms.message )
582
+ − 490
{
628
+ − 491
var body = document.createElement('p');
+ − 492
var message = parms.message.split(unescape('%0A'));
+ − 493
for ( var i = 0; i < message.length; i++ )
+ − 494
{
+ − 495
body.appendChild(document.createTextNode(message[i]));
+ − 496
if ( i + 1 < message.length )
+ − 497
body.appendChild(document.createElement('br'));
+ − 498
}
582
+ − 499
}
+ − 500
+ − 501
parent.style.textAlign = 'center';
+ − 502
628
+ − 503
if ( parms.title )
+ − 504
parent.appendChild(h3);
+ − 505
if ( parms.message )
+ − 506
parent.appendChild(body);
582
+ − 507
parent.appendChild(document.createElement('br'));
+ − 508
+ − 509
// construct buttons
+ − 510
for ( var i = 0; i < parms.buttons.length; i++ )
+ − 511
{
+ − 512
var button = parms.buttons[i];
+ − 513
button.input = document.createElement('a');
+ − 514
button.input.href = '#';
+ − 515
button.input.clickAction = button.onclick;
+ − 516
button.input.className = 'abutton';
+ − 517
if ( button.color )
+ − 518
{
+ − 519
button.input.className += ' abutton_' + button.color;
+ − 520
}
+ − 521
button.input.appendChild(document.createTextNode(button.text));
+ − 522
if ( button.style )
+ − 523
{
+ − 524
for ( var j in button.style )
+ − 525
{
+ − 526
button.input.style[j] = button.style[j];
+ − 527
}
+ − 528
}
673
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 529
if ( button.image )
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 530
{
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 531
button.input.className += ' abutton_img';
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 532
button.input.style.backgroundImage = 'url(' + button.image + ')';
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 533
}
582
+ − 534
button.input.onclick = function(e)
+ − 535
{
+ − 536
try
+ − 537
{
+ − 538
this.clickAction(e);
+ − 539
}
+ − 540
catch(e)
+ − 541
{
+ − 542
console.error(e);
+ − 543
}
+ − 544
return false;
+ − 545
}
+ − 546
parent.appendChild(button.input);
+ − 547
}
694
43367c66d869
Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
diff
changeset
+ − 548
// don't focus this in opera - it looks kinda ugly
43367c66d869
Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
diff
changeset
+ − 549
if ( parms.buttons[0] && !window.opera )
582
+ − 550
{
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 551
var timeout = ( aclDisableTransitionFX ) ? 10 : 1000;
582
+ − 552
setTimeout(function()
+ − 553
{
+ − 554
parms.buttons[0].input.focus();
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 555
}, timeout);
582
+ − 556
}
+ − 557
}
+ − 558
catch ( e )
+ − 559
{
+ − 560
console.error(e);
+ − 561
}
+ − 562
});
+ − 563
}
+ − 564
+ − 565
function testMPMessageBox()
+ − 566
{
+ − 567
miniPromptMessage({
+ − 568
title: 'The Game of LIFE question #73',
+ − 569
message: 'You just got your girlfriend pregnant. Please select an option:',
+ − 570
buttons: [
+ − 571
{
+ − 572
text: 'Abort',
+ − 573
color: 'red',
+ − 574
style: {
+ − 575
fontWeight: 'bold'
+ − 576
},
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 577
image: cdnPath + '/images/icons/abort.png',
582
+ − 578
onclick: function() {
+ − 579
miniPromptDestroy(this);
+ − 580
}
+ − 581
},
+ − 582
{
+ − 583
text: 'Retry',
+ − 584
color: 'blue',
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 585
image: cdnPath + '/images/icons/retry.png',
582
+ − 586
onclick: function() {
+ − 587
miniPromptDestroy(this);
+ − 588
}
+ − 589
},
+ − 590
{
+ − 591
text: 'Ignore',
+ − 592
color: 'green',
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 593
image: cdnPath + '/images/icons/ignore.png',
582
+ − 594
onclick: function() {
+ − 595
miniPromptDestroy(this);
+ − 596
}
+ − 597
}
+ − 598
]
+ − 599
});
+ − 600
}
+ − 601