closes #551, ability to minimize annotations

This commit is contained in:
Simon Kornblith 2007-03-13 08:44:28 +00:00
parent bb0fe85b52
commit 8eeefc16e7
9 changed files with 86 additions and 7 deletions

View File

@ -41,6 +41,7 @@ var Zotero_Browser = new function() {
this.scrapeThisPage = scrapeThisPage;
this.annotatePage = annotatePage;
this.toggleMode = toggleMode;
this.setCollapsed = setCollapsed;
this.chromeLoad = chromeLoad;
this.chromeUnload = chromeUnload;
this.contentLoad = contentLoad;
@ -167,6 +168,14 @@ var Zotero_Browser = new function() {
}
}
/*
* expands all annotations
*/
function setCollapsed(status) {
var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
tab.page.annotations.setCollapsed(status);
}
/*
* called to hide the collection selection popup
*/

View File

@ -315,6 +315,8 @@
<!-- Annotation Toolbar -->
<toolbar id="zotero-annotate-tb" crop="end" insertbefore="content" hidden="true">
<toolbarbutton id="zotero-annotate-tb-add" tooltiptext="&zotero.annotate.toolbar.add.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
<toolbarbutton id="zotero-annotate-tb-collapse" tooltiptext="&zotero.annotate.toolbar.collapse.label;" oncommand="Zotero_Browser.setCollapsed(true);"/>
<toolbarbutton id="zotero-annotate-tb-expand" tooltiptext="&zotero.annotate.toolbar.expand.label;" oncommand="Zotero_Browser.setCollapsed(false);"/>
<toolbarbutton id="zotero-annotate-tb-highlight" tooltiptext="&zotero.annotate.toolbar.highlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
<toolbarbutton id="zotero-annotate-tb-unhighlight" tooltiptext="&zotero.annotate.toolbar.unhighlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
</toolbar>

View File

@ -511,6 +511,12 @@ Zotero.Annotations.prototype.load = function() {
}
}
Zotero.Annotations.prototype.setCollapsed = function(status) {
for each(var annotation in this.annotations) {
annotation.setCollapsed(status);
}
}
//////////////////////////////////////////////////////////////////////////////
//
// Zotero.Annotation
@ -653,9 +659,13 @@ Zotero.Annotation.prototype.displayWithAbsoluteCoordinates = function(absX, absY
var startScroll = this.window.scrollMaxX;
if(!this.div) {
var me = this;
var body = this.document.getElementsByTagName("body")[0];
// generate regular div
this.div = this.document.createElement("div");
this.div.setAttribute("zotero", "annotation");
this.document.getElementsByTagName("body")[0].appendChild(this.div);
body.appendChild(this.div);
this.div.style.backgroundColor = Zotero.Annotate.annotationColor;
this.div.style.padding = "0";
this.div.style.display = "block";
@ -664,10 +674,24 @@ Zotero.Annotation.prototype.displayWithAbsoluteCoordinates = function(absX, absY
this.div.style.borderColor = Zotero.Annotate.annotationBorderColor;
this.div.style.MozOpacity = 0.9;
this.div.style.zIndex = this.annotationsObj.zIndex;
var me = this;
this.div.addEventListener("click", function() { me._click() }, false);
this._addChildElements();
// generate pushpin div
this.pushpinDiv = this.document.createElement("div");
this.pushpinDiv.style.padding = "0";
this.pushpinDiv.style.display = "block";
this.pushpinDiv.style.position = "absolute";
this.pushpinDiv.style.MozOpacity = 0.9;
this.pushpinDiv.style.cursor = "pointer";
// generate pushpin image
var img = this.document.createElement("img");
img.src = "chrome://zotero/skin/annotation-hidden.png";
img.addEventListener("click", function() {
me.setCollapsed(false);
}, false);
this.pushpinDiv.appendChild(img);
body.appendChild(this.pushpinDiv);
}
this.div.style.display = "block";
this.div.style.left = absX+"px";
@ -679,6 +703,24 @@ Zotero.Annotation.prototype.displayWithAbsoluteCoordinates = function(absX, absY
}
}
Zotero.Annotation.prototype.setCollapsed = function(status) {
if(status == true) {
// hide div
this.div.style.display = "none";
// move pushpin div
this.pushpinDiv.style.left = this.div.style.left;
this.pushpinDiv.style.top = this.div.style.top;
this.pushpinDiv.style.zIndex = this.div.style.zIndex;
// show pushpin div
this.pushpinDiv.style.display = "block";
} else {
// hide pushpin div
this.pushpinDiv.style.display = "none";
// show div
this.div.style.display = "block";
}
}
Zotero.Annotation.prototype._generateMarker = function(offset) {
// first, we create a new span at the correct offset in the node
var range = this.document.createRange();
@ -710,13 +752,15 @@ Zotero.Annotation.prototype._addChildElements = function() {
bar.style.height = "10px";
bar.style.borderColor = Zotero.Annotate.annotationBorderColor;
// close box
// left box
var closeDiv = this.document.createElement("div");
closeDiv.style.display = "block";
closeDiv.style.position = "absolute";
closeDiv.style.left = "1px";
closeDiv.style.top = "1px";
closeDiv.style.cursor = "pointer";
// close image
var img = this.document.createElement("img");
img.src = "chrome://zotero/skin/annotation-close.png";
img.addEventListener("click", function(event) {
@ -724,22 +768,34 @@ Zotero.Annotation.prototype._addChildElements = function() {
me._delete();
}
}, false);
closeDiv.appendChild(img);
bar.appendChild(closeDiv);
// move box
// right box
var moveDiv = this.document.createElement("div");
moveDiv.style.display = "block";
moveDiv.style.position = "absolute";
moveDiv.style.right = "1px";
moveDiv.style.top = "1px";
moveDiv.style.cursor = "pointer";
// move image
this.moveImg = this.document.createElement("img");
this.moveImg.src = "chrome://zotero/skin/annotation-move.png";
this.moveImg.addEventListener("click", function(e) {
me._startMove(e);
me._startMove();
}, false);
moveDiv.appendChild(this.moveImg);
// hide image
var img = this.document.createElement("img");
img.src = "chrome://zotero/skin/annotation-hide.png";
img.addEventListener("click", function(event) {
me.setCollapsed(true);
}, false);
moveDiv.appendChild(img);
bar.appendChild(moveDiv);
// grippy
@ -786,7 +842,7 @@ Zotero.Annotation.prototype._click = function() {
}
Zotero.Annotation.prototype._confirmDelete = function(event) {
if (event.target.parentNode.nextSibling.value == '' ||
if (this.textarea.value == '' ||
!Zotero.Prefs.get('annotations.warnOnClose')) {
return true;
}

View File

@ -97,5 +97,7 @@
<!ENTITY zotero.citation.line "Line">
<!ENTITY zotero.annotate.toolbar.add.label "Add Annotation">
<!ENTITY zotero.annotate.toolbar.collapse.label "Collapse All Annotations">
<!ENTITY zotero.annotate.toolbar.expand.label "Expand All Annotations">
<!ENTITY zotero.annotate.toolbar.highlight.label "Highlight Text">
<!ENTITY zotero.annotate.toolbar.unhighlight.label "Unhighlight Text">

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

View File

@ -254,6 +254,16 @@
list-style-image: url('chrome://zotero/skin/annotate-add.png');
}
#zotero-annotate-tb-collapse
{
list-style-image: url('chrome://zotero/skin/annotate-collapse-all.png');
}
#zotero-annotate-tb-expand
{
list-style-image: url('chrome://zotero/skin/annotate-expand-all.png');
}
#zotero-annotate-tb-highlight
{
list-style-image: url('chrome://zotero/skin/annotate-highlight.png');