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
{
811
5c807fe77020
Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
diff
changeset
+ − 299
(mb.onclick[val])();
582
+ − 300
}
+ − 301
}
+ − 302
+ − 303
function testMessageBox()
+ − 304
{
+ − 305
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');
+ − 306
mb.onclick['OK'] = function()
+ − 307
{
+ − 308
alert('You clicked OK!');
+ − 309
}
+ − 310
mb.onbeforeclick['Cancel'] = function()
+ − 311
{
+ − 312
alert('You clicked Cancel!');
+ − 313
}
+ − 314
}
+ − 315
+ − 316
/**
+ − 317
* The miniPrompt function, for creating small prompts and dialogs. The window will be flown in and the window darkened with opac=0.4.
+ − 318
* @param function Will be passed an HTMLElement that is the body of the prompt window; the function can do with this as it pleases
+ − 319
*/
+ − 320
+ − 321
function miniPrompt(call_on_create)
+ − 322
{
+ − 323
if ( !aclDisableTransitionFX )
+ − 324
{
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
+ − 325
load_component(['flyin', 'jquery', 'jquery-ui', 'fadefilter']);
582
+ − 326
}
854
+ − 327
else
+ − 328
{
+ − 329
load_component(['fadefilter']);
+ − 330
}
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
+ − 331
var darkener = darken(aclDisableTransitionFX, 40, 'miniprompt_darkener');
582
+ − 332
+ − 333
var wrapper = document.createElement('div');
+ − 334
wrapper.className = 'miniprompt';
+ − 335
var top = document.createElement('div');
+ − 336
top.className = 'mp-top';
+ − 337
var body = document.createElement('div');
+ − 338
body.className = 'mp-body';
+ − 339
var bottom = document.createElement('div');
+ − 340
bottom.className = 'mp-bottom';
+ − 341
if ( typeof(call_on_create) == 'function' )
+ − 342
{
+ − 343
call_on_create(body);
+ − 344
}
+ − 345
wrapper.appendChild(top);
+ − 346
wrapper.appendChild(body);
+ − 347
wrapper.appendChild(bottom);
+ − 348
var left = ( getWidth() / 2 ) - ( 388 / 2 );
+ − 349
wrapper.style.left = left + 'px';
+ − 350
var top = getScrollOffset() - 27;
+ − 351
wrapper.style.top = top + 'px';
+ − 352
domObjChangeOpac(0, wrapper);
+ − 353
var realbody = document.getElementsByTagName('body')[0];
+ − 354
realbody.appendChild(wrapper);
+ − 355
+ − 356
if ( aclDisableTransitionFX )
+ − 357
{
+ − 358
domObjChangeOpac(100, wrapper);
+ − 359
}
+ − 360
else
+ − 361
{
+ − 362
fly_in_top(wrapper, true, true);
+ − 363
+ − 364
setTimeout(function()
+ − 365
{
+ − 366
domObjChangeOpac(100, wrapper);
+ − 367
}, 40);
+ − 368
}
628
+ − 369
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
+ − 370
// 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
+ − 371
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
+ − 372
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
+ − 373
{
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
+ − 374
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
+ − 375
{
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
+ − 376
$(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
+ − 377
}
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
+ − 378
}
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
+ − 379
628
+ − 380
return wrapper;
582
+ − 381
}
+ − 382
+ − 383
/**
+ − 384
* 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.
+ − 385
* @param object:HTMLElement Child node to scan
+ − 386
* @return object
+ − 387
*/
+ − 388
+ − 389
function miniPromptGetParent(obj)
+ − 390
{
+ − 391
while ( true )
+ − 392
{
+ − 393
// prevent infinite loops
+ − 394
if ( !obj || obj.tagName == 'BODY' )
+ − 395
return false;
+ − 396
+ − 397
if ( $dynano(obj).hasClass('miniprompt') )
+ − 398
{
+ − 399
return obj;
+ − 400
}
+ − 401
obj = obj.parentNode;
+ − 402
}
+ − 403
return false;
+ − 404
}
+ − 405
+ − 406
/**
+ − 407
* Destroys the first miniPrompt div encountered by recursively checking all parent nodes.
+ − 408
* Usage: <a href="javascript:miniPromptDestroy(this);">click</a>
+ − 409
* @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
+ − 410
* @param bool (DEPRECATED) If true, does not call enlighten().
582
+ − 411
*/
+ − 412
+ − 413
function miniPromptDestroy(obj, nofade)
+ − 414
{
+ − 415
obj = miniPromptGetParent(obj);
+ − 416
if ( !obj )
+ − 417
return false;
+ − 418
+ − 419
// found it
+ − 420
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
+ − 421
// 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
+ − 422
// enlighten(aclDisableTransitionFX);
887
+ − 423
enlighten((aclDisableTransitionFX || nofade), 'miniprompt_darkener');
+ − 424
if ( aclDisableTransitionFX || nofade )
582
+ − 425
{
+ − 426
parent.removeChild(obj);
+ − 427
}
+ − 428
else
+ − 429
{
+ − 430
var timeout = fly_out_top(obj, true, true);
+ − 431
setTimeout(function()
+ − 432
{
+ − 433
parent.removeChild(obj);
+ − 434
}, timeout);
+ − 435
}
+ − 436
}
+ − 437
+ − 438
/**
+ − 439
* Simple test case
+ − 440
*/
+ − 441
+ − 442
function miniPromptTest()
+ − 443
{
+ − 444
miniPrompt(function(div) { div.innerHTML = 'hello world! <a href="#" onclick="miniPromptDestroy(this); return false;">destroy me</a>'; });
+ − 445
}
+ − 446
+ − 447
/**
+ − 448
* Message box system for miniPrompts. Less customization but easier to scale than the regular messageBox framework.
+ − 449
* @example
+ − 450
<code>
+ − 451
miniPromptMessage({
+ − 452
title: 'Delete page',
+ − 453
message: 'Do you really want to delete this page? This is reversible unless you clear the page logs.',
+ − 454
buttons: [
+ − 455
{
+ − 456
text: 'Delete',
+ − 457
color: 'red',
+ − 458
style: {
+ − 459
fontWeight: 'bold'
+ − 460
},
+ − 461
onclick: function() {
+ − 462
ajaxDeletePage();
+ − 463
miniPromptDestroy(this);
+ − 464
}
+ − 465
},
+ − 466
{
+ − 467
text: 'cancel',
+ − 468
onclick: function() {
+ − 469
miniPromptDestroy(this);
+ − 470
}
+ − 471
}
+ − 472
]
+ − 473
});
+ − 474
</code>
+ − 475
*/
+ − 476
+ − 477
function miniPromptMessage(parms)
+ − 478
{
628
+ − 479
if ( ( !parms.title && !parms.message ) || !parms.buttons )
582
+ − 480
return false;
+ − 481
+ − 482
return miniPrompt(function(parent)
+ − 483
{
+ − 484
try
+ − 485
{
628
+ − 486
if ( parms.title )
+ − 487
{
+ − 488
var h3 = document.createElement('h3');
+ − 489
h3.appendChild(document.createTextNode(parms.title));
+ − 490
}
+ − 491
if ( parms.message )
582
+ − 492
{
628
+ − 493
var body = document.createElement('p');
+ − 494
var message = parms.message.split(unescape('%0A'));
+ − 495
for ( var i = 0; i < message.length; i++ )
+ − 496
{
+ − 497
body.appendChild(document.createTextNode(message[i]));
+ − 498
if ( i + 1 < message.length )
+ − 499
body.appendChild(document.createElement('br'));
+ − 500
}
582
+ − 501
}
+ − 502
+ − 503
parent.style.textAlign = 'center';
+ − 504
628
+ − 505
if ( parms.title )
+ − 506
parent.appendChild(h3);
+ − 507
if ( parms.message )
+ − 508
parent.appendChild(body);
582
+ − 509
parent.appendChild(document.createElement('br'));
+ − 510
+ − 511
// construct buttons
+ − 512
for ( var i = 0; i < parms.buttons.length; i++ )
+ − 513
{
+ − 514
var button = parms.buttons[i];
+ − 515
button.input = document.createElement('a');
+ − 516
button.input.href = '#';
+ − 517
button.input.clickAction = button.onclick;
+ − 518
button.input.className = 'abutton';
+ − 519
if ( button.color )
+ − 520
{
+ − 521
button.input.className += ' abutton_' + button.color;
+ − 522
}
+ − 523
button.input.appendChild(document.createTextNode(button.text));
+ − 524
if ( button.style )
+ − 525
{
+ − 526
for ( var j in button.style )
+ − 527
{
+ − 528
button.input.style[j] = button.style[j];
+ − 529
}
+ − 530
}
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 531
if ( button.sprite )
673
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 532
{
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 533
var sprite = gen_sprite(button.sprite[0], button.sprite[1], button.sprite[2], button.sprite[3], button.sprite[4]);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 534
sprite.style.position = 'relative';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 535
sprite.style.top = '3px';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 536
button.input.insertBefore(sprite, button.input.firstChild);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 537
insertAfter(button.input, document.createTextNode(' '), sprite);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 538
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 539
else if ( button.image )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 540
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 541
button.input.className += ' icon';
673
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 542
button.input.style.backgroundImage = 'url(' + button.image + ')';
99c617146a34
Added abutton_img class + supporting properties in miniPromptMessage to allow icons on abuttons
Dan
diff
changeset
+ − 543
}
582
+ − 544
button.input.onclick = function(e)
+ − 545
{
+ − 546
try
+ − 547
{
+ − 548
this.clickAction(e);
+ − 549
}
+ − 550
catch(e)
+ − 551
{
+ − 552
console.error(e);
+ − 553
}
+ − 554
return false;
+ − 555
}
+ − 556
parent.appendChild(button.input);
+ − 557
}
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
+ − 558
// 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
+ − 559
if ( parms.buttons[0] && !window.opera )
582
+ − 560
{
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
+ − 561
var timeout = ( aclDisableTransitionFX ) ? 10 : 1000;
582
+ − 562
setTimeout(function()
+ − 563
{
+ − 564
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
+ − 565
}, timeout);
582
+ − 566
}
+ − 567
}
+ − 568
catch ( e )
+ − 569
{
+ − 570
console.error(e);
+ − 571
}
+ − 572
});
+ − 573
}
+ − 574
906
+ − 575
/**
+ − 576
* Identical to whiteOutElement(), but safe to call on miniPrompt divs.
+ − 577
*/
+ − 578
+ − 579
function whiteOutMiniPrompt(el)
+ − 580
{
+ − 581
var top = getScrollOffset();
+ − 582
var left = ( getWidth() / 2 ) - ( 320 / 2);
+ − 583
var width = 320;
+ − 584
var height = $dynano(el).Height() - 58;
+ − 585
+ − 586
var blackout = document.createElement('div');
+ − 587
// using fixed here allows modal windows to be blacked out
+ − 588
blackout.style.position = ( el.style.position == 'fixed' ) ? 'fixed' : 'absolute';
+ − 589
blackout.style.top = top + 'px';
+ − 590
blackout.style.left = left + 'px';
+ − 591
blackout.style.width = width + 'px';
+ − 592
blackout.style.height = height + 'px';
+ − 593
+ − 594
blackout.style.backgroundColor = '#FFFFFF';
+ − 595
domObjChangeOpac(60, blackout);
+ − 596
var background = ( $dynano(el).Height() < 48 ) ? 'url(' + scriptPath + '/images/loading.gif)' : 'url(' + scriptPath + '/includes/clientside/tinymce/themes/advanced/skins/default/img/progress.gif)';
+ − 597
blackout.style.backgroundImage = background;
+ − 598
blackout.style.backgroundPosition = 'center center';
+ − 599
blackout.style.backgroundRepeat = 'no-repeat';
+ − 600
blackout.style.zIndex = '1000';
+ − 601
+ − 602
var body = document.getElementsByTagName('body')[0];
+ − 603
body.appendChild(blackout);
+ − 604
+ − 605
return blackout;
+ − 606
}
+ − 607
582
+ − 608
function testMPMessageBox()
+ − 609
{
+ − 610
miniPromptMessage({
+ − 611
title: 'The Game of LIFE question #73',
+ − 612
message: 'You just got your girlfriend pregnant. Please select an option:',
+ − 613
buttons: [
+ − 614
{
+ − 615
text: 'Abort',
+ − 616
color: 'red',
+ − 617
style: {
+ − 618
fontWeight: 'bold'
+ − 619
},
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 620
sprite: [ cdnPath + '/images/icons/abortretryignore-sprite.png', 16, 16, 0, 0 ],
582
+ − 621
onclick: function() {
+ − 622
miniPromptDestroy(this);
+ − 623
}
+ − 624
},
+ − 625
{
+ − 626
text: 'Retry',
+ − 627
color: 'blue',
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 628
sprite: [ cdnPath + '/images/icons/abortretryignore-sprite.png', 16, 16, 0, 16 ],
582
+ − 629
onclick: function() {
+ − 630
miniPromptDestroy(this);
+ − 631
}
+ − 632
},
+ − 633
{
+ − 634
text: 'Ignore',
+ − 635
color: 'green',
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 636
sprite: [ cdnPath + '/images/icons/abortretryignore-sprite.png', 16, 16, 0, 32 ],
582
+ − 637
onclick: function() {
+ − 638
miniPromptDestroy(this);
+ − 639
}
+ − 640
}
+ − 641
]
+ − 642
});
+ − 643
}
+ − 644