diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 0064101fb..bbc4fb9bb 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -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 */ diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index e0146e3fc..b78348fcd 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -315,6 +315,8 @@ diff --git a/chrome/content/zotero/xpcom/annotate.js b/chrome/content/zotero/xpcom/annotate.js index 4f573609d..16a3eae97 100644 --- a/chrome/content/zotero/xpcom/annotate.js +++ b/chrome/content/zotero/xpcom/annotate.js @@ -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; } diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index edebbb0bb..e9841adbf 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -97,5 +97,7 @@ + + \ No newline at end of file diff --git a/chrome/skin/default/zotero/annotate-collapse-all.png b/chrome/skin/default/zotero/annotate-collapse-all.png new file mode 100644 index 000000000..d0131e934 Binary files /dev/null and b/chrome/skin/default/zotero/annotate-collapse-all.png differ diff --git a/chrome/skin/default/zotero/annotate-expand-all.png b/chrome/skin/default/zotero/annotate-expand-all.png new file mode 100644 index 000000000..aac23982d Binary files /dev/null and b/chrome/skin/default/zotero/annotate-expand-all.png differ diff --git a/chrome/skin/default/zotero/annotation-hidden.png b/chrome/skin/default/zotero/annotation-hidden.png new file mode 100644 index 000000000..b376a21fc Binary files /dev/null and b/chrome/skin/default/zotero/annotation-hidden.png differ diff --git a/chrome/skin/default/zotero/annotation-hide.png b/chrome/skin/default/zotero/annotation-hide.png new file mode 100644 index 000000000..5630dc6e9 Binary files /dev/null and b/chrome/skin/default/zotero/annotation-hide.png differ diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index 9d542e4a2..3cfa7bcff 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -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');