From 8eeefc16e7e9ede01813c179b3032f8e7a01c7a2 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 13 Mar 2007 08:44:28 +0000 Subject: [PATCH] closes #551, ability to minimize annotations --- chrome/content/zotero/browser.js | 9 +++ chrome/content/zotero/overlay.xul | 2 + chrome/content/zotero/xpcom/annotate.js | 70 ++++++++++++++++-- chrome/locale/en-US/zotero/zotero.dtd | 2 + .../default/zotero/annotate-collapse-all.png | Bin 0 -> 670 bytes .../default/zotero/annotate-expand-all.png | Bin 0 -> 678 bytes .../skin/default/zotero/annotation-hidden.png | Bin 0 -> 462 bytes .../skin/default/zotero/annotation-hide.png | Bin 0 -> 403 bytes chrome/skin/default/zotero/overlay.css | 10 +++ 9 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 chrome/skin/default/zotero/annotate-collapse-all.png create mode 100644 chrome/skin/default/zotero/annotate-expand-all.png create mode 100644 chrome/skin/default/zotero/annotation-hidden.png create mode 100644 chrome/skin/default/zotero/annotation-hide.png diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 0064101fbf..bbc4fb9bb8 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 e0146e3fc0..b78348fcd0 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 4f573609d6..16a3eae978 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 edebbb0bb4..e9841adbf7 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 0000000000000000000000000000000000000000..d0131e934e8b4222fd1ea8a5b570f8b2c76cecf1 GIT binary patch literal 670 zcmV;P0%84$P)$%i@H-6{sRTYWx&V2pbHnSbffJ`5f_5H`e^CKML-1+ znv|l@A`M8PsI6M5G}@S^W@1Pt$vkqe-;GJDF%`iB-#s&T&N*}L?_BNl^@%Z%h}P zHJ9G;#BWmoi_Fkf=9j-=G_l~S*|&0OLKR$;I&?(`{`wRMr;~2SgZP3&f03Fd7sDWz zJh|v@8lAcO2z-A8SC#LHA{RcVQfo5Q+ENgp@G6k5MK4e+O0fa4oso+=)*f=HmaDj1O3y+Dk3$#($fjOnHG|m3Ro=q7 zsVVAe$W56mFNeNbWkic5AkE~pb)H{cV|9-Iu^$2q0Oa9P{&%=pApigX07*qoM6N<$ Eg07Y|mH+?% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..aac23982d878323969ec95541c1eabc663dc9f39 GIT binary patch literal 678 zcmV;X0$KfuP)vVD1xTcD%4$dZ8r*v%Yupv>7r7Ly0x3?P7z$`##&mb3m4f4 zD)vFJ&@2)t#e#{IYJH)tHOY`RX)>=n{x>F8Ln1x!-!pUPoHOTs=PGA!jUNKgOSPi5 z6{$&T>dEz!U#dU4sJ`A)9UYx*0XUUiXVdAX<&D1iem*?&eji_NRu@pI12WlWv@HP3 z1`OfA;D&Aqc-$@=Js6a+p<3;^Dt~ggSWI*rr}Qkih*Bp4|1()YQ52MdopREKJ%>-(uX5B3rCw?5dk?_`$Ueh1R@$AU5U9h_;m}w(yYvzy)s>@)j_Dg^P0B6BJ_8c84TL1t6 M07*qoM6N<$f_rN<<^TWy literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/annotation-hidden.png b/chrome/skin/default/zotero/annotation-hidden.png new file mode 100644 index 0000000000000000000000000000000000000000..b376a21fc0e5ccaafe81e29f30ddb60abe7ba184 GIT binary patch literal 462 zcmV;<0WtoGP)!EPYVT3+FPhY_lAW1y9iUy!vj0}C?~PF-71Jz!X} z@8%sKQ=0{-i3iB=4zX2X`22%`;pdEJ^XUgr&3^_KCWwMRU|S$I!7u~Ef3SuxKYoL#cTB(#`U3Lzn!|S(M1a0k5N2dh z7GYvg6JuiFVP|Cc`E=v{{0=O14Iasxrp!2r^T4M()^xbyto*Z*^OT>TGZe+S}PWO=ZS=m6+~UPpbI zqWu@2dP)fBj|1qZK3v9L2S%F2j~F#P(c#a;l^`d?EMus+!La=pzf#(1D^Pf{yjQfDDf~eWSt4|lc`to}o7aP+dCSVYNg9F3>8OzMd xknsK2-$$!Y-p}V?V>-dZ&V&d@Vgno?zyQ;7d3BI$>m~pI002ovPDHLkV1fxWyq5p~ literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index 9d542e4a24..3cfa7bcffe 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');