diff options
Diffstat (limited to 'pyload/webui/themes/Dark/lib/MooTools/MooDialog/MooDialog.Prompt.js')
-rw-r--r-- | pyload/webui/themes/Dark/lib/MooTools/MooDialog/MooDialog.Prompt.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pyload/webui/themes/Dark/lib/MooTools/MooDialog/MooDialog.Prompt.js b/pyload/webui/themes/Dark/lib/MooTools/MooDialog/MooDialog.Prompt.js new file mode 100644 index 000000000..c693e4a58 --- /dev/null +++ b/pyload/webui/themes/Dark/lib/MooTools/MooDialog/MooDialog.Prompt.js @@ -0,0 +1,48 @@ +/* +--- +name: MooDialog.Prompt +description: Creates a Prompt dialog +authors: Arian Stolwijk +license: MIT-style license +requires: MooDialog +provides: MooDialog.Prompt +... +*/ + + +MooDialog.Prompt = new Class({ + + Extends: MooDialog, + + options: { + okText: 'Ok', + focus: true, + textPClass: 'MooDialogPrompt', + defaultValue: '' + }, + + initialize: function(msg, fn, options){ + this.parent(options); + if (!fn) fn = function(){}; + + var textInput = new Element('input.textInput', {type: 'text', value: this.options.defaultValue}), + submitButton = new Element('input[type=submit]', {value: this.options.okText}), + formEvents = { + submit: function(e){ + e.stop(); + fn(textInput.get('value')); + this.close(); + }.bind(this) + }; + + this.setContent( + new Element('p.' + this.options.textPClass, {text: msg}), + new Element('form.buttons', {events: formEvents}).adopt(textInput, submitButton) + ); + if (this.options.autoOpen) this.open(); + + if (this.options.focus) this.addEvent('show', function(){ + textInput.focus(); + }); + } +}); |