This is an example of expanded content that will cause the flyout's content to scroll
Types
Flyout
A flyout
Your inbox is getting full, would you like us to enable automatic archiving of old messages?
Variations
Width
A flyout can specify its width.
Width can also be defined like the ui grid system.
Position
A flyout can specify its display position.
Fullscreen
A flyout can take all the entire screen if needed.
Scrolling Content
A flyout can have a scrolling content
Very long content goes here
Center Aligned
You can center align the header, the content or even actions individually
Content is centered
Left Actions
You can also place the action buttons to the left
They are aligned to the left
Basic Header and Actions
Header and/or Actions can also appear on the same basic background as the content
Basic Actions below
Examples
Using a custom context
A flyout can be initialized inside any element, not just a page's body
.
Your inbox is getting full, would you like us to enable automatic archiving of old messages?
Application Content
Set-up
Page Structure
Using a flyout requires a specific page structure. For optimal performance your page should be already set-up with this structure before initializing a flyout.
Initializing a flyout
Via existing DOM node
A flyout can be included anywhere on the page. On initialization a flyout's current size will be cached, and the element will be detached from the DOM and moved inside a dimmer.
Via Javascript properties
You can create temporary flyouts without the need to create markup on your own. Temporary flyouts will be removed from the DOM once closed by default if there isn't a custom onHidden
callback given.
Behavior
All the following behaviors can be called using the syntax:
Behavior | Description |
---|---|
attach events(selector, event) | Attaches flyout action to given selector. Default event if none specified is toggle |
show | Shows the flyout |
hide | Hides the flyout |
toggle | Toggles the flyout |
hide others | Hides all other displayed flyouts |
is visible | Returns whether the flyout is visible |
is hidden | Returns whether the flyout is hidden |
get direction | Returns direction of current flyout |
get settings | Returns current flyout's settings |
destroy | Destroys instance and removes all events |
Config Templates
A config template is a special behavior to immediately show preconfigured temporary flyouts. Three basic templates are included: alert
, confirm
, prompt
as equivalents to existing vanilla JS variants, but with more possibilities to customize the look & feel.
Alert
Possible parameters are: title, content, handler (in that order to stay nearly identical to vanilla js usage) or a given object {title:'',content:'',handler:function(){}}
where as title and content can contain HTML.
Confirm
The parameter list and logic is the same as for alert. The selected boolean choice will be provided to a given callback handler.
Prompt
The call for prompt is basically identical to alert and confirm. There are 2 more options available when an object is given placeholder
and defaultValue
.
If you provide HTML Code for the content and this contains an input, this will be used as the inputfield. Otherwise it creates one dynamically for you.
Create your own template
By extending the flyouts templates object once, you can define your own custom config templates. It has to return an object which will be merged into the flyouts settings prior to creating/showing the flyout.
is the best!', closeIcon: true, class: 'inverted', classContent: 'centered' } }
Reuse this whenever you need
Settings
Flyout Settings
Flyout settings modify the flyout's behavior.
Setting | Default | Description |
---|---|---|
context | 'body' |
Selector or jquery object specifying the area to dim |
exclusive | false |
Opening another flyout will dismiss the one displayed. Set to true to allow multiple flyout at the same time. |
closable | true |
Setting to false will not allow you to close the flyout by clicking on the dimmer. |
dimPage | true |
Whether to dim context contents when flyout is visible. |
blurring | false |
If dimmer should blur background |
autofocus | true |
When true, the first form input inside the flyout will receive focus when shown. Set this to false to prevent this behavior. |
restoreFocus | true |
When false, the last focused element, before the flyout was shown, will not get refocused again when the flyout hides. This could prevent unwanted scrolling behaviors after closing a flyout. |
keyboardShortcuts | true |
Whether to automatically bind keyboard shortcuts. This will close the flyout when the ESC-key is pressed. |
scrollLock | false |
Whether to lock page scroll when flyout is visible. |
returnScroll | false |
Whether to return to original scroll position when flyout is hidden. |
delaySetup | false |
When flyout is initialized without the proper HTML, using this option will defer creation of DOM to use requestAnimationFrame . |
autoShow | false |
When true, immediately shows the flyout at instantiation time. |
Callbacks
Callbacks specify a function to occur after a specific behavior.
Setting | Context | Description |
---|---|---|
onChange | Flyout | Is called when a flyout is either shown or hidden. |
onShow | Flyout | Is called when a flyout starts to show. |
onHide | Flyout | Is called after a flyout starts to hide. |
onVisible | Flyout | Is called after a flyout has finished showing animating. |
onHidden | Flyout | Is called after a flyout has finished hiding animation. |
onApprove | Flyout | Is called after a positive, approve or ok button is pressed. If the function returns false , the flyout will not hide. |
onDeny | Flyout | Is called after a negative, deny or cancel button is pressed. If the function returns false , the flyout will not hide. |
DOM Settings
DOM settings specify how this module should interface with the DOM.
Setting | Default | Description |
---|---|---|
namespace | flyout | Event namespace. Makes sure module teardown does not effect other events attached to an element. |
selector |
selector : {
fixed : '.fixed',
omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
pusher : '.pusher',
flyout : '.ui.flyout',
header : '.ui.header',
content : '.content',
actions : '.actions',
close : '.close',
approve : '.actions .positive, .actions .approve, .actions .ok',
deny : '.actions .negative, .actions .deny, .actions .cancel'
}
|
|
className |
className : {
flyout : 'ui flyout',
close : 'close icon',
header : 'ui header',
content : 'content',
actions : 'actions',
active : 'active',
animating : 'animating',
dimmed : 'dimmed',
pushable : 'pushable',
pushed : 'pushed',
right : 'right',
top : 'top',
left : 'left',
bottom : 'bottom',
visible : 'visible',
overlay : 'overlay',
fullscreen : 'fullscreen',
template : 'ui flyout',
button : 'ui button',
ok : 'positive',
cancel : 'negative',
prompt : 'ui fluid input'
}
|
|
regExp |
regExp : {
mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
}
|
Config Template Settings
Config Template Settings define default content for dynamically created flyouts.
Setting | Default | Description |
---|---|---|
title | '' |
Content of the flyout header. |
content | '' |
Content of the flyout content. |
class | '' |
Can hold a string to be added to the flyout class to control its appearance. |
classTitle | '' |
Can hold a string to be added to the title class to control its appearance. |
classContent | '' |
Can hold a string to be added to the content class to control its appearance. |
classActions | '' |
Can hold a string to be added to the actions class to control its appearance. |
closeIcon | false |
Whether the flyout should include a close icon. |
actions | false |
An array of objects. Each object defines an action with properties text ,class ,icon and click .
actions: [{
text : 'Wait',
class : 'red',
icon : 'exclamation',
click : function() {}
}]
|
preserveHTML | true |
Whether HTML included in given title, content or actions should be preserved. Set to false in case you work with untrusted 3rd party content. |
fields |
fields : {
class : 'class',
text : 'text',
icon : 'icon',
click : 'click'
}
|
|
text |
text: {
ok : 'Ok',
cancel: 'Cancel'
}
|
Debug Settings
Debug settings controls debug output to the console.
Setting | Default | Description |
---|---|---|
name | Flyout |
Name used in debug logs. |
silent | false |
Silences all console output including error messages, regardless of other debug settings. |
debug | false |
Provides standard debug output to console. |
performance | true |
Show console.table output with performance metrics. |
verbose | true |
Debug output includes all internal behaviors. |
error |
error : {
method : 'The method you called is not defined.',
pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
movedFlyout : 'Had to move flyout. For optimal performance make sure flyout and pusher are direct children of your body tag',
notFound : 'There were no elements that matched the specified selector'
}
|