(protected) new MarkupLayer(viewerControl, markReferencesopt)
The `MarkupLayer` object is used to group together marks and their associated comments. A layer may be persisted to the web tier using IPCC.ViewerControl#saveMarkupLayer. Also, a layer may be stored in a IPCC.MarkupLayerCollection where it can be retrieved for later use. When creating a layer, mark references may be added. A mark reference is a JSON object that represents a comment that refers to a mark on another layer. When the current user comments on a mark that does not exist in his layer, then his persisted layer record will contain a reference to the mark while the full mark will exist in another record. Because records might be loaded out of order or in an incomplete set, this parameter provides a way to store the mark reference. If the record containing the full mark loads later then the data stored here can be attached to it. After creating a layer, marks may be added and removed from it. The `MarkupLayer` object also provides an event subscription method, to get notified of other types of information. See IPCC.MarkupLayer.EventType.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
viewerControl |
string | The IPCC.ViewerControl for the loaded document. | |
markReferences |
Object | Array.<Object> | <optional> |
The JSON reference node (or an array of them) from the markup layer record. |
Example
// Optionally, specify any references to marks on another layer or layers
var markReference = {
creationDateTime: "2015-06-12T21:20:58.527Z"
data: {
"key1": "value1",
"key2": "value2"
},
markUid: "ZZZrOV8yMDE1LTA2LTExVDE5OjU5OjEwLjE3MlpfNDg2dzI5"
text: "user 1 comment on user 3 mark"
};
// Create a new layer
var layer = new IPCC.MarkupLayer(viewerControl, markReference)
// Create a new mark
var mark = viewerControl.addMark(1, 'TextAnnotation');
// Add the mark to the layer
layer.addMarks(mark)
// Determine if a mark is contained in a layer
var markInLayer = layer.hasMark(mark.getId())
//register some events
layer
.on(IPCC.MarkupLayer.EventType.MarkupLayerCreated,
function(ev) {
alert("Markup layer created.");
})
.on(IPCC.MarkupLayer.EventType.MarkupLayerDestroyed,
function(ev) {
alert("Markup layer destroyed.");
})
.on(IPCC.MarkupLayer.EventType.MarksAddedToLayer,
function(event) {
alert("Mark added to layer: " + ev.marks[0].getId());
})
.on(IPCC.MarkupLayer.EventType.MarksRemovedFromLayer,
function(event) {
alert("Mark removed from layer: " + ev.marks[0].getId());
})
.on(IPCC.MarkupLayer.EventType.MarkupLayerInteractionModeChanged,
function(event) {
alert("Layer's interaction mode changed to: " + ev.interactionMode);
})
.on(IPCC.MarkupLayer.EventType.MarkupLayerHidden,
function(event) {
alert("MarkupLayer#show() called.");
})
.on(IPCC.MarkupLayer.EventType.MarkupLayerShown,
function(event) {
alert("MarkupLayer#hide() called.");
});
Members
(static, readonly) EventType :string
A list of events that can be triggered by the IPCC.MarkupLayer object. **Note:** This enumeration is for convenience for API developers. Instead of using this enumeration, you can pass string values of the eventType (enumeration values)
Type:
- string
Properties:
Name | Type | Description |
---|---|---|
MarkupLayerCreated |
string | |
MarkupLayerDestroyed |
string | |
MarksAddedToLayer |
string | |
MarksRemovedFromLayer |
string | |
MarkupLayerInteractionModeChanged |
string | |
MarkupLayerHidden |
string | |
MarkupLayerShown |
string |
(readonly) id :Object
Gets the layer's ID. This property is defined on all MarkupLayer objects. _This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods._
Type:
- Object
Example
var id = MarkupLayer.id;
name :Object
Gets and sets the layer's name. This property is defined on all MarkupLayer objects. _This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods._
Type:
- Object
Example
var name = MarkupLayer.name;
originalXmlName :Object
Gets and sets the layer's original XML name. This property is defined on all MarkupLayer objects. _This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods._
Type:
- Object
Example
var name = MarkupLayer.originalXmlName;
(readonly) recordId :Object
Gets the ID of web tier record from which this layer was created. This property is defined on all MarkupLayer objects. _This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods._
Type:
- Object
Example
var recordId = MarkupLayer.recordId;
(readonly) viewerControl :Object
Gets the viewer control associated with this layer. This property is defined on all MarkupLayer objects. _This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods._
Type:
- Object
Example
var viewerControl = MarkupLayer.viewerControl;
Methods
addMarks(A) → {IPCC.MarkupLayer}
Used to add marks to the layer.
Parameters:
Name | Type | Description |
---|---|---|
A |
IPCC.Mark | Array.<IPCC.Mark> | {IPCC.Mark} object or an array of them. |
Returns:
The markup layer Object.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var mark = viewerControl.addMark(1, 'TextAnnotation'); // Create a new mark
markupLayer.addMarks(mark);
copyLayers(marks) → {IPCC.MarkupLayer}
Copies marks from other layers to this layer. **Note:** The copied marks are assigned new unique IDs, and any references to the original mark (such as a comment on the mark that is stored in another layer) will not reference the copied mark. A copy of each comment on the mark is put on the copy of the mark in this layer.
Parameters:
Name | Type | Description |
---|---|---|
marks |
Array.<IPCC.MarkupLayer> | An array of markup layers to copy to this layer. |
Throws:
-
If markupLayers is not an array of markup layers known to the viewer.
- Type
- Error
Returns:
The markup layer Object on which this method was called.
- Type
- IPCC.MarkupLayer
Example
var markupLayer1 = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var markupLayer2 = viewerControl.getMarkupLayerCollection().getAll()[1]; // Get the second markup layer.
var markupLayer4 = viewerControl.getMarkupLayerCollection().getAll()[3]; // Get the fourth markup layer.
// Concatenate layers 2 and 4 to a single array.
var layersToCopy = markupLayer2.concat(markupLayer4);
// Copy the layers to this layer.
markupLayer1.copyLayers(layersToCopy);
destroy()
This method will remove the layer from the viewer control's markup layer collection. Also, it will de-register any event listeners associated with the layer.
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.destroy();
getId() → {string}
Gets the layer's ID.
Returns:
The ID of the layer.
- Type
- string
getMarkReferences() → {Array.<Object>}
Gets the mark references associated with this layer.
Returns:
An array of mark reference Objects.
- Type
- Array.<Object>
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var markReferences = markupLayer.getMarkReferences();
getMarks() → {Array.<IPCC.Mark>}
Gets the marks associated with this layer.
Returns:
An array of {IPCC.Mark} Objects.
- Type
- Array.<IPCC.Mark>
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var marks = markupLayer.getMarks();
getName() → {string}
Gets the layer's name.
Returns:
The name of the layer.
- Type
- string
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var layerName = markupLayer.getName();
getOriginalXmlName() → {string}
Gets the name of the web tier XML record from which the marks of this layer were originally stored.
Returns:
The name of the web tier XML record from which the marks of this layer were originally stored.
- Type
- string
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var originalXmlName = markupLayer.getOriginalXmlName();
getRecordId() → {string}
Gets the ID of web tier record from which this layer was created.
Returns:
The layer record ID
- Type
- string
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var recordId = markupLayer.getRecordId();
getViewerControl() → {IPCC.ViewerControl}
Gets the viewer control associated with this layer.
Returns:
A viewer control object.
- Type
- IPCC.ViewerControl
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var viewerControl = markupLayer.getViewerControl();
hasMark(A) → {boolean}
Used to query the layer to see if it contains a particular mark.
Parameters:
Name | Type | Description |
---|---|---|
A |
string | mark's id. |
Returns:
A true or false indication depending on whether the mark exists in the layer.
- Type
- boolean
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
var mark = viewerControl.getAllMarks()[0];
var markExistsInLayer = markupLayer.hasMark(mark.getId());
hide() → {IPCC.MarkupLayer}
Hides all of the marks in the layer.
Returns:
The markup layer Object on which this method was called.called.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.hide(); // Hide the marks in the layer.
off(eventType) → {IPCC.MarkupLayer}
Unsubscribe an event handler from a specified event type. Typically, an event is unsubscribed when you no longer want further notification of the event.
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | A string specifying the event type. See IPCC.MarkupLayer.EventType for a list and description of all supported events. |
`IPCC.Event~eventHandler` |
handler A function that was attached previously to the `ViewerControl`. **Note:** This must be the same function object previously passed to IPCC.MarkupLayer#on. It cannot be a different object that is functionally equivalent. |
- See:
-
- IPCC.MarkupLayer#on
- IPCC.ViewerControl#off for more details on unsubscribing event handlers.
Returns:
The `MarkupLayer` object on which this method was called.
- Type
- IPCC.MarkupLayer
on(eventType) → {IPCC.MarkupLayer}
Subscribe an event handler to an event of a specified type.
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | A string that specifies the event type. This value is case-insensitive. See IPCC.MarkupLayer.EventType for a list and description of all supported events. |
`IPCC.Event~eventHandler` |
handler A function that will be called whenever the event is triggered. |
- See:
-
- IPCC.MarkupLayer#off
- IPCC.ViewerControl#on for more details on event subscription.
Returns:
The `MarkupLayer` object on which this method was called.
- Type
- IPCC.MarkupLayer
removeMarks(A) → {IPCC.MarkupLayer}
Used to remove marks from the layer.
Parameters:
Name | Type | Description |
---|---|---|
A |
IPCC.Mark | Array.<IPCC.Mark> | {IPCC.Mark} object or an array of them. |
Returns:
The markup layer Object.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getActiveMarkupLayer(); // Get the active markup layer.
var mark = viewerControl.addMark(1, 'TextAnnotation'); // Create a new mark
markupLayer.removeMarks(mark); // remove the mark from the active layer
setInteractionMode(interactionMode) → {IPCC.MarkupLayer}
Used to alter the interaction mode of all marks in a layer.
Parameters:
Name | Type | Description |
---|---|---|
interactionMode |
string | A string value from the enumeration IPCC.Mark.InteractionMode, |
Returns:
The markup layer Object on which this method was called
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.setInteractionMode(IPCC.Mark.InteractionMode.SelectionDisabled);
setName(name) → {IPCC.MarkupLayer}
Sets the layer's name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name to apply to this layer. |
Returns:
The markup layer Object on which this method was called.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.setName('Final Draft');
setOriginalXmlName(name) → {IPCC.MarkupLayer}
Sets the name of the web tier XML record from which the marks of this layer were originally stored. If the layer is not associated with an XML file, the property should be set to an empty string. When the original XML name is set and a markup layer is saved, the original XML name is saved in the markup layer JSON. When the IPCC.ViewerControl#requestMarkupLayerNames method is called, the original XML name will be provided.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the web tier XML record from which the marks of this layer were originally stored. |
Returns:
The markup layer Object on which this method was called.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.setOriginalXmlName('my marks');
show() → {IPCC.MarkupLayer}
Shows all of the marks in the layer.
Returns:
The markup layer Object on which this method was called.
- Type
- IPCC.MarkupLayer
Example
var markupLayer = viewerControl.getMarkupLayerCollection().getAll()[0]; // Get the first markup layer.
markupLayer.show(); // Show the marks in the layer.