Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Example
Define a context menu in the masonry layout for performing cut and paste operation:
<oj-masonry-layout>
<oj-menu slot="contextMenu">
<oj-option data-oj-command="oj-masonrylayout-cut" ></oj-option>
<oj-option data-oj-command="oj-masonrylayout-paste-before" ></oj-option>
<oj-option data-oj-command="oj-masonrylayout-paste-after" ></oj-option>
</oj-menu>
</oj-masonry-layout>
Slots
JET elements can have up to two types of child content:
- Any child element with a
slotattribute will be moved into that named slot, e.g.<span slot='startIcon'>...</span>. All supported named slots are documented below. Child elements with unsupported named slots will be removed from the DOM. - Any child element lacking a
slotattribute will be moved to the default slot, also known as a regular child. This is documented under the "Default" heading below.
-
Default
-
<oj-masonry-layout> accepts arbitrary direct child elements that can be sized and positioned, which it will lay out as a grid of tiles. Each direct child element must be styled using one of the predefined
oj-masonrylayout-tile-CxRstyle classes to specify the size of that tile. A tile can span multiple columns and/or rows.Example
Initialize the masonry layout with child content specified:
<oj-masonry-layout> <div class='oj-masonrylayout-tile-2x1'>Alpha</div> <div class='oj-masonrylayout-tile-1x2'>Beta</div> <div class='oj-masonrylayout-tile-1x1'>Gamma</div> <div class='oj-masonrylayout-tile-1x1'>Delta</div> <div class='oj-masonrylayout-tile-1x1'>Epsilon</div> <div class='oj-masonrylayout-tile-1x1'>Zeta</div> </oj-masonry-layout> -
contextMenu
-
The contextMenu slot is set on the
oj-menuwithin this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.
To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc and demos of the individual components for details.
Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.
Example
Initialize the component with a context menu:
<oj-some-element> <-- use the contextMenu slot to designate this as the context menu for this component --> <oj-menu slot="contextMenu" style="display:none" aria-label="Some element's context menu"> ... </oj-menu> </oj-some-element>
Attributes
-
(nullable) reorder-handle :string
-
Specify the selector of the descendant DOM element in a
oj-masonry-layoutchild that can be used to reorder the child by drag-and-drop.This attribute value is
nullby default, meaning thatoj-masonry-layoutchildren cannot be reordered. If each child that can be reordered has an element with style class'my-reorder-handle', then thereorder-handleattribute would be specified as'.my-reorder-handle'.When specifying a
reorder-handle, the application should also specify a context menu with actions to cut and paste tiles as an accessible alternative to drag-and-drop reordering.To specify a context menu, see the documentation of oj-menu.
- Default Value:
null
Names
Item Name Property reorderHandleProperty change event reorderHandleChangedProperty change listener attribute (must be of type function) on-reorder-handle-changedExamples
Initialize the masonryLayout with the
reorder-handleattribute specified:<oj-masonry-layout reorder-handle='.my-reorder-handle'> <div id='child1'> <div class='my-reorder-handle'/> </div> <div id='child2'> <div class='my-reorder-handle'/> </div> <!-- additional child elements... --> </oj-masonry-layout>Get or set the
reorderHandleproperty after initialization:// getter var contentParent = myMasonryLayout.reorderHandle; // setter myMasonryLayout.reorderHandle = '.my-reorder-handle'; -
translations :Object|null
-
A collection of translated resources from the translation bundle, or
nullif this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.If the component does not contain any translatable resource, the default value of this attribute will be
null. If not, an object containing all resources relevant to the component.If this component has translations, their documentation immediately follows this doc entry.
Names
Item Name Property translationsProperty change event translationsChangedProperty change listener attribute (must be of type function) on-translations-changedExamples
Initialize the component, overriding some translated resources and leaving the others intact:
<!-- Using dot notation --> <oj-some-element translations.some-key='some value' translations.some-other-key='some other value'></oj-some-element> <!-- Using JSON notation --> <oj-some-element translations='{"someKey":"some value", "someOtherKey":"some other value"}'></oj-some-element>Get or set the
translationsproperty after initialization:// Get one var value = myComponent.translations.someKey; // Set one, leaving the others intact. Always use the setProperty API for // subproperties rather than setting a subproperty directly. myComponent.setProperty('translations.someKey', 'some value'); // Get all var values = myComponent.translations; // Set all. Must list every resource key, as those not listed are lost. myComponent.translations = { someKey: 'some value', someOtherKey: 'some other value' }; -
(nullable) translations.label-cut :string
-
Context menu text used for cutting a tile.
See the translations attribute for usage examples.
- Default Value:
"Cut"
- Since:
- 1.1.0
Names
Item Name Property translations.labelCut -
(nullable) translations.label-paste-after :string
-
Context menu text used for pasting a tile after another tile.
See the translations attribute for usage examples.
- Default Value:
"Paste After"
- Since:
- 1.1.0
Names
Item Name Property translations.labelPasteAfter -
(nullable) translations.label-paste-before :string
-
Context menu text used for pasting a tile before another tile.
See the translations attribute for usage examples.
- Default Value:
"Paste Before"
- Since:
- 1.1.0
Names
Item Name Property translations.labelPasteBefore
Events
-
ojAnimateEnd
-
Triggered when a default animation has ended.
- "insert" - when a tile is inserted
- "move" - when a tile is moved
- "remove" - when a tile is removed
- "resize" - when a tile is resized
- "reorder" - when a tile is reordered
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description actionstring The action that triggers the animation. Supported values are: elementElement The element being animated. Examples
Specify an
ojAnimateEndlistener via the DOM attribute:<oj-masonry-layout on-oj-animate-end='[[listener]]'></oj-masonry-layout>Specify an
ojAnimateEndlistener via the JavaScript property:myMasonryLayout.onOjAnimateEnd = listener;Add an
ojAnimateEndlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojAnimateEnd', listener); -
ojAnimateStart
-
Triggered when a default animation is about to start on the element.
The default animation can be cancelled by calling
event.preventDefault(), followed by a call toevent.detail.endCallback().event.detail.endCallback()should be called immediately afterevent.preventDefault()if the application merely wants to cancel animation, or it should be called when the custom animation ends if the application is invoking another animation function. Failure to callevent.detail.endCallback()may prevent the element from working properly.For more information on customizing animations, see the documentation of oj.AnimationUtils.
The default animations are controlled via the theme (SCSS) : $masonryLayoutInsertAnimation: ((effect: "zoomIn", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out"), "fadeIn") !default; $masonryLayoutRemoveAnimation: ((effect: "zoomOut", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out"), "fadeOut") !default; $masonryLayoutMoveAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out", transitionProperties: ('top', 'left', 'right')) !default; $masonryLayoutResizeAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out", transitionProperties: ('width', 'height', 'top', 'left', 'right')) !default; $masonryLayoutReorderAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDurationFast, timingFunction: "ease-in-out", transitionProperties: ('width', 'height', 'top', 'left', 'right')) !default;- "insert" - when a tile is inserted
- "move" - when a tile is moved
- "remove" - when a tile is removed
- "resize" - when a tile is resized
- "reorder" - when a tile is reordered
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description actionstring The action that triggers the animation. Supported values are:
Note that some animation effects may not look appropriate for a given action.elementElement The element being animated. endCallbackfunction():void If the event listener calls event.preventDefault to cancel the default animation, it must call the endCallback function after it finishes its own animation handling and any custom animation has ended. Examples
Specify an
onOjAnimateStartlistener to override the default "insert" animation with a custom animation:myMasonryLayout.onOjAnimateStart = function( event ) { if (!$(event.target).is("oj-masonry-layout")) return; var ui = event.detail; // Change the insert animation if (ui.action == "insert") { event.preventDefault(); // Invoke new animation and call event.detail.endCallback when it ends oj.AnimationUtils.fadeIn(ui.element).then(ui.endCallback); } }Specify an
onOjAnimateStartlistener to prevent the default "remove" animation:myMasonryLayout.onOjAnimateStart = function( event ) { if (!$(event.target).is("oj-masonry-layout")) return; var ui = event.detail; // Prevent the remove animation if (ui.action == "remove") { event.preventDefault(); ui.endCallback(); } }Specify an
ojAnimateStartlistener via the DOM attribute:<oj-masonry-layout on-oj-animate-start='[[listener]]'></oj-masonry-layout>Specify an
ojAnimateStartlistener via the JavaScript property:myMasonryLayout.onOjAnimateStart = listener;Add an
ojAnimateStartlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojAnimateStart', listener); -
ojBeforeInsert
-
Triggered immediately before a tile is inserted. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that is about to be inserted. indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile will be inserted.Examples
Specify an
ojBeforeInsertlistener via the DOM attribute:<oj-masonry-layout on-oj-before-insert='[[listener]]'></oj-masonry-layout>Specify an
ojBeforeInsertlistener via the JavaScript property:myMasonryLayout.onOjBeforeInsert = listener;Add an
ojBeforeInsertlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojBeforeInsert', listener); -
ojBeforeRemove
-
Triggered immediately before a tile is removed. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that will be removed. Examples
Specify an
ojBeforeRemovelistener via the DOM attribute:<oj-masonry-layout on-oj-before-remove='[[listener]]'></oj-masonry-layout>Specify an
ojBeforeRemovelistener via the JavaScript property:myMasonryLayout.onOjBeforeRemove = listener;Add an
ojBeforeRemovelistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojBeforeRemove', listener); -
ojBeforeReorder
-
Triggered immediately before a tile is reordered. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that will be reordered. fromIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren from which the tile will be reordered.Examples
Specify an
ojBeforeReorderlistener via the DOM attribute:<oj-masonry-layout on-oj-before-reorder='[[listener]]'></oj-masonry-layout>Specify an
ojBeforeReorderlistener via the JavaScript property:myMasonryLayout.onOjBeforeReorder = listener;Add an
ojBeforeReorderlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojBeforeReorder', listener); -
ojBeforeResize
-
Triggered immediately before a tile is resized. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that will be resized. previousSizeStyleClassstring The previous size style class applied to the tile. sizeStyleClassstring The new size style class that will be applied to the tile. Examples
Specify an
ojBeforeResizelistener via the DOM attribute:<oj-masonry-layout on-oj-before-resize='[[listener]]'></oj-masonry-layout>Specify an
ojBeforeResizelistener via the JavaScript property:myMasonryLayout.onOjBeforeResize = listener;Add an
ojBeforeResizelistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojBeforeResize', listener); -
ojInsert
-
Triggered immediately after a tile is inserted.
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that was inserted. indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile was inserted.Examples
Specify an
ojInsertlistener via the DOM attribute:<oj-masonry-layout on-oj-insert='[[listener]]'></oj-masonry-layout>Specify an
ojInsertlistener via the JavaScript property:myMasonryLayout.onOjInsert = listener;Add an
ojInsertlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojInsert', listener); -
ojRemove
-
Triggered immediately after a tile is removed.
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that was removed. Examples
Specify an
ojRemovelistener via the DOM attribute:<oj-masonry-layout on-oj-remove='[[listener]]'></oj-masonry-layout>Specify an
ojRemovelistener via the JavaScript property:myMasonryLayout.onOjRemove = listener;Add an
ojRemovelistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojRemove', listener); -
ojReorder
-
Triggered immediately after a tile is reordered.
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that was reordered. fromIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren from which the tile was reordered.toIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren to which the tile was reordered.Examples
Specify an
ojReorderlistener via the DOM attribute:<oj-masonry-layout on-oj-reorder='[[listener]]'></oj-masonry-layout>Specify an
ojReorderlistener via the JavaScript property:myMasonryLayout.onOjReorder = listener;Add an
ojReorderlistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojReorder', listener); -
ojResize
-
Triggered immediately after a tile is resized.
Properties:
All of the event payloads listed below can be found under
event.detail.Name Type Description tileElement The tile that was resized. previousSizeStyleClassstring The previous size style class applied to the tile. sizeStyleClassstring The new size style class applied to to the tile. Examples
Specify an
ojResizelistener via the DOM attribute:<oj-masonry-layout on-oj-resize='[[listener]]'></oj-masonry-layout>Specify an
ojResizelistener via the JavaScript property:myMasonryLayout.onOjResize = listener;Add an
ojResizelistener via theaddEventListenerAPI:myMasonryLayout.addEventListener('ojResize', listener);
Methods
-
getProperty(property) → {any}
-
Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. - Since:
- 4.0.0
Returns:
- Type
- any
Example
Get a single subproperty of a complex property:
var subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2'); -
insertTile(selector, index) → {void}
-
Insert a tile into the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to insert. The tile does not need to be a child of the oj-masonry-layoutwhen this method is called. This method will reparent the tile to theoj-masonry-layout.indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile will be inserted.Returns:
- Type
- void
Example
Invoke the
insertTilemethod:myMasonryLayout.insertTile('#tileSelector', 2); -
refresh() → {void}
-
Refreshes the visual state of the masonryLayout. JET elements require a
refresh()after the DOM is programmatically changed underneath the element.This method does not accept any arguments.
Returns:
- Type
- void
Example
Invoke the
refreshmethod:myMasonryLayout.refresh(); -
removeTile(selector) → {void}
-
Remove a tile from the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to remove. Returns:
- Type
- void
Example
Invoke the
removeTilemethod:myMasonryLayout.removeTile('#tileSelector'); -
resizeTile(selector, sizeStyleClass) → {void}
-
Resize a tile in the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to resize. sizeStyleClassstring New size style class to apply to the tile. Returns:
- Type
- void
Example
Invoke the
resizeTilemethod:myMasonryLayout.resizeTile('#tileSelector', 'oj-masonrylayout-tile-2x1'); -
setProperties(properties) → {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesObject An object containing the property and value pairs to set. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a batch of properties:
myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"}); -
setProperty(property, value) → {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a single subproperty of a complex property:
myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");