Lightweight, beautiful and clean Mootools plugin to show dialogs on your sites and web-apps. Inspired by Mootools and MochaUI.
Simple alert
new MUX.Dialog({ title: 'Alert!', content: new Element('p', {html: 'Beware, this is an alert!'}), buttons: [{ title: 'OK', click: 'close' }] });
More examples of dialogs and code see here http://lavmax.github.com/MUX.Dialog
zIndex - (int, defaults to 10000) Defines start zIndex property for all dialog's HTML element. It's recommended to set dialog's zIndex as the largest for your project. Example MUX.Dialog.prototype.zIndex = 100000;.
var dialog = new MUX.Dialog([options]);
title - (string) Header's title text.
modal - (boolean, defaults to true) Turn on/off modal mode.
resizable - (boolean, defaults to false) If dialog can be manually resized by user. The dialog can be resized by dragging the right-bottom corner. Non-resizable mode means that it changes its size depends on content and is not resizable manually. true turns dialog into non-elastic mode, so content should be elastic and adjust to the dialog size, so when user will resize the window content should properly resize itself.
closable - (boolean, defaults to true) If the dialog can be closed by default close button in the header and by Esc or not.
autoOpen - (boolean, defaults to true) Setting to true opens the dialog right after creation, otherwise use open() of created object.
showHeader - (boolean or 'invisible', defaults to true) Show/hide dialog's header. 'invisible' mode means that header will have the same background as a window and will not be visible by itself. The Close button (if applicable) will be visible.
showFooter - (boolean or 'auto', defaults to 'auto') Show/hide dialogs's footer. If 'auto' footer is displayed if there is at least one button defined in options.
size - (object) Internal content size without header, footer and content padding. Possible keys are:
position - (object) Initial position of the dialog. Possible keys are:
content - (element or string) Element will be placed in the content element. String is treated like an URL for getting HTML by Request.HTML.
buttons - (array of objects) Buttons are placed from left to right. Each object defines dialog button and can have keys:
defaultButton - (int or undefined, defaults to undefined) Index (from left to right) of the default dialog's button. Defining this property sets keydown event listener for the content element that catches Enter pressed and fires button click event.
loader - ('none' or 'manual' or 'auto', defaults to 'auto'). Adds AJAX animation icon near buttons. It users MUX.Loader.XXX classes. If these classes are not attached this option will be ignored. If 'none' - no loader is available. If 'manual' loader will be available and you should start and stop it from code. If 'auto' it plays with onSubmit event, starts animation when event fired and stops when dialog is closing. If submission failed (e.g. didn't pass validation) and you don't need to close dialog you should stop animation manually. For more information see MUX.Loaders documentation.
box - (element) General dialog element without modal overlay.
header - (element) Header element.
content - (element) Content element.
footer - (element) Footer element.
loader - (MUX.Loader.XXX or undefined) Loader object if MUX.Loaders library is attached and loader option is set to manual or auto. Otherwise undefined.
buttons - (array of MUX.Button objects) Dialog buttons from left to right.
open() - Opens dialog if it was closed or created with autoOpen set to false. Returns dialog instance.
close([delay]) - Close dialog and destroys elements. Parameter sets close delay in ms and in if is set the dialog is close with fading. You can use close(1) to close with fading without delay.
position() - Position dialog onto initial coordinates according to options. Returns dialog instance.
moveToTop() - Moves dialog to the top of other dialogs. Returns dialog instance.
open - (option onOpen) Fires when content is loaded (if ajax) and placed, the dialog is open but still invisible. Dialog will position after firing the event.
close - (option onClose) On close dialog. This is the right place to write some common things to execute on close.
submit - (option onSubmit) This event fires on click buttons with 'submit' value for 'click' option and helps to keep your code more structured.
MUX.Button is a separate class that is used in MUX.Dialog but could be also uses by itself if you like it.
var button = new MUX.Button([options]);
title - (string) Button text.
click - (function) Function that is fired on button click.
style - ('ellipse' or 'rectangle' or 'native' or 'auto' or 'link', defaults to 'auto') Button look style. 'ellipse' means rounded buttons, 'rectangle' means rectangle button with a little bit rounded corners, 'native' means native button look, which depends on browser and OS, 'link' means that button looks like a link (text with underline on hover), 'auto' means that button look will be detected automatically depends on browser and OS.
context - (object) click function will fire in context of given object and this will point to it. If undefined or null this will point to button element.
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus