mirror of
https://github.com/pattern-lab/patternlab-php.git
synced 2025-01-17 14:18:30 +01:00
annotation code clean-up
This commit is contained in:
parent
61b5b4cad4
commit
a16fc25b01
@ -21,9 +21,7 @@ var annotationsPattern = {
|
|||||||
gatherComments: function() {
|
gatherComments: function() {
|
||||||
|
|
||||||
// make sure this only added when we're on a pattern specific view
|
// make sure this only added when we're on a pattern specific view
|
||||||
if (document.getElementById("sg-patterns") === null) {
|
if (document.getElementById("sg-patterns") !== null) {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
var obj = { "commentOverlay": "off" };
|
var obj = { "commentOverlay": "off" };
|
||||||
var targetOrigin = (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
var targetOrigin = (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
||||||
@ -119,7 +117,6 @@ var annotationsPattern = {
|
|||||||
els = document.querySelectorAll(".has-annotation");
|
els = document.querySelectorAll(".has-annotation");
|
||||||
for (i = 0; i < els.length; i++) {
|
for (i = 0; i < els.length; i++) {
|
||||||
els[i].classList.remove("has-annotation");
|
els[i].classList.remove("has-annotation");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,39 +135,38 @@ var annotationsPattern = {
|
|||||||
item = comments.comments[i];
|
item = comments.comments[i];
|
||||||
els = document.querySelectorAll(item.el),
|
els = document.querySelectorAll(item.el),
|
||||||
displayNum = i+1;
|
displayNum = i+1;
|
||||||
|
|
||||||
//Loop through all items with annotations
|
//Loop through all items with annotations
|
||||||
for (k = 0; k < els.length; k++) {
|
for (k = 0; k < els.length; k++) {
|
||||||
els[k].classList.add("has-annotation");
|
els[k].classList.add("has-annotation");
|
||||||
|
|
||||||
var numberDiv = document.createElement("a");
|
var numberDiv = document.createElement("a");
|
||||||
numberDiv.href = "#annotation-" + displayNum;
|
numberDiv.href = "#annotation-" + displayNum;
|
||||||
numberDiv.classList.add("annotation-tip");
|
numberDiv.classList.add("annotation-tip");
|
||||||
|
|
||||||
els[k].appendChild(numberDiv);
|
els[k].appendChild(numberDiv);
|
||||||
numberDiv.innerHTML = displayNum;
|
numberDiv.innerHTML = displayNum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// count elements so it can be used when displaying the results in the viewer
|
|
||||||
var count = 0;
|
|
||||||
|
|
||||||
// iterate over the comments in annotations.js
|
|
||||||
for(i = 0; i < comments.comments.length; i++) {
|
|
||||||
|
|
||||||
var item = comments.comments[i];
|
// count elements so it can be used when displaying the results in the viewer
|
||||||
var els = document.querySelectorAll(item.el);
|
var count = 0;
|
||||||
|
|
||||||
// if an element is found in the given pattern add it to the overall object so it can be passed when the overlay is turned on
|
// iterate over the comments in annotations.js
|
||||||
if (els.length > 0) {
|
for(i = 0; i < comments.comments.length; i++) {
|
||||||
|
|
||||||
annotationsPattern.commentsGathered.comments[count] = { "el": item.el, "title": item.title, "comment": item.comment };
|
var item = comments.comments[i];
|
||||||
count++;
|
var els = document.querySelectorAll(item.el);
|
||||||
|
|
||||||
|
// if an element is found in the given pattern add it to the overall object so it can be passed when the overlay is turned on
|
||||||
|
if (els.length > 0) {
|
||||||
|
annotationsPattern.commentsGathered.comments[count] = { "el": item.el, "title": item.title, "comment": item.comment };
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
annotationsPattern.commentsGathered.count = count;
|
||||||
|
|
||||||
annotationsPattern.commentsGathered.count = count;
|
|
||||||
|
|
||||||
// send the list of annotations for the page back to the parent
|
// send the list of annotations for the page back to the parent
|
||||||
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user