|
TABLE
MAKE
CUSTOMIZE
EFFECTS
EFFECTS CYCLE
EFFECTS CYCLES
VIRTUAL BOX
PLUG-IN
GLIDER
|
Custom.Prompt
Do you want prompts from many different operating systems in the same page? You can.
In this example you can see an Apple prompt, a Windows XP prompt, and a Windows Vista prompt. But the Custom prompts are not normal prompt boxes like standards: you can pick an overlay, decide if enable dragging, set an opacity transition and many, many more. And you can decide whether create a multi or a single prompt. window.addEvent('domready', function() { // IE6 style fix if(Browser.Engine.trident4) { new Asset.css('/examples/1.3.1/custom_confirm/style_ie6.css', {id: 'style_ie6'}); } // APPLE Prompt var cc1 = new Custom.Prompt('', '<b>JavaScript</b> <br /><br /> <span class="little">An Apple multi-Prompt</span>', { content: 'html', draggable: false, text: { confirmButtonText: '', closeButtonText: '', cancelButtonText: '' }, opacify:false, promptType: { box: 'multi', lines: 4, startValue: 'Type something here into this Apple multi-prompt' }, zones: { box: 'box1', head: 'head1', body: 'body1', buttonBox: 'buttonBox1', promptBox: 'promptBox1' }, buttons: { closeButton: 'closeButton1', confirmButton: 'confirmButton1', cancelButton: 'cancelButton1' }, overlay: '#D3D3D3', onConfirm: function(input) { if(input == '') input = 'an empy string'; $('confirm1').set('html', 'You clicked OK with the first prompt and you typed <b>' + input.stripScripts() + '</b>'); }, onCancel: function() { $('confirm1').set('html', '<b>You typed Cancel with the first prompt</b>'); }, initialize: function() { this.theclose = new Element('div', { 'styles': {'clear': 'both'} }); this.theclose.injectInside(this.closebox); } }); // WINDOWS Prompt var cc2 = new Custom.Prompt('<span><b>XP Prompt</b></span>', '<b>JavaScript</b> <br /><br /> <span class="little">A Windows Prompt</span>', { content: 'html', text: { confirmButtonText: '', closeButtonText: '', cancelButtonText: '' }, opacify:false, draggable: false, zones: { box: 'box2', head: 'head2', body: 'body2', buttonBox: 'buttonBox2', promptBox: 'promptBox2' }, buttons: { closeButton: 'closeButton2', confirmButton: 'confirmButton2', cancelButton: 'cancelButton2' }, overlay: 'darken', onConfirm: function(input) { if(input == '') input = 'an empy string'; $('confirm2').set('html', 'You clicked OK with the second prompt and you typed <b>' + input.stripScripts() + '</b>'); }, onCancel: function() { $('confirm2').set('html', '<b>You typed Cancel with the second prompt</b>'); }, initialize: function() { this.theclose = new Element('div', { 'styles': {'clear': 'both'} }); this.theclose.injectInside(this.closebox); } }); // VISTA Prompt var cc3 = new Custom.Prompt('<span>Vista Prompt</span>', '<b>JavaScript</b> <br /><br /> <span class="little">A Vista Prompt</span>', { content: 'html', text: { confirmButtonText: '', closeButtonText: '', cancelButtonText: '' }, opacify:false, draggable:false, promptType: { startValue: 'Type something here' }, zones: { box: 'box3', head: 'head3', body: 'body3', buttonBox: 'buttonBox3', promptBox: 'promptBox3' }, buttons: { closeButton: 'closeButton3', confirmButton: 'confirmButton3', cancelButton: 'cancelButton3' }, overlay: 'lighten', onConfirm: function(input) { if(input == '') input = 'an empy string'; $('confirm3').set('html', 'You clicked OK with the third prompt and you typed <b>' + input.stripScripts() + '</b>'); }, onCancel: function() { $('confirm3').set('html', '<b>You typed Cancel with the third prompt</b>'); }, initialize: function() { this.theclose = new Element('div', { 'styles': {'clear': 'both'} }); this.theclose.injectInside(this.closebox); } }); // EVENTS $('ok').addEvent('click', function(event) { event.preventDefault(); cc1.setText('<b>Javascript</b> <br /> <br /> <span class="little">Same prompt with new text</span>'); cc1.setLight('lighten'); $('change').set('html', '<b>Changed text and light of the first confirm</b>'); }); $('ok2').addEvent('click', function(event) { event.preventDefault(); cc1.create(); }); $('ok3').addEvent('click', function(event) { event.preventDefault(); cc2.create(); }); $('ok4').addEvent('click', function(event) { event.preventDefault(); cc3.create(); }); }); |