fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-09-09 11:01 am

[dw-free] Collapse Cut button at end of cut

[commit: http://hg.dwscoalition.org/dw-free/rev/33bdd00ad982]

http://bugs.dwscoalition.org/show_bug.cgi?id=2879

Left-facing closing arrow at the end of relatively long blocks of expanded
cuts (at least 100px high).

Patch by [personal profile] fu.

Files modified:
  • htdocs/img/collapse-end.gif
  • htdocs/js/cuttag-ajax.js
--------------------------------------------------------------------------------
diff -r 311ee07e1b7e -r 33bdd00ad982 htdocs/img/collapse-end.gif
Binary file htdocs/img/collapse-end.gif has changed
diff -r 311ee07e1b7e -r 33bdd00ad982 htdocs/js/cuttag-ajax.js
--- a/htdocs/js/cuttag-ajax.js	Thu Sep 09 13:48:33 2010 +0800
+++ b/htdocs/js/cuttag-ajax.js	Thu Sep 09 19:00:54 2010 +0800
@@ -6,6 +6,12 @@ CutTagHandler = new Class(Object, {
     init: function(journal, ditemid, cutid) {
       this.identifier = 'cuttag_' + journal + '_' + ditemid + '_' + cutid;
       this.ajaxUrl = "/__rpc_cuttag?journal=" + journal + "&ditemid=" + ditemid + "&cutid=" + cutid;
+
+      this.data = {
+        journal: journal,
+        ditemid: ditemid,
+        cutid: cutid
+      };
     },
 
     // returns if the div controlled by this handler is open
@@ -61,6 +67,14 @@ CutTagHandler = new Class(Object, {
         var replaceDiv = $('div-' + this.identifier);
         replaceDiv.innerHTML=resObj.text;
         replaceDiv.style.display="block";
+
+        if ( replaceDiv.offsetHeight > 100 ) {
+            var closeEnd = document.createElement("span");
+
+            closeEnd.innerHTML = ' <a href="#span-'+this.identifier+'" onclick=" CutTagHandler.toggleCutTag(\''+this.data.journal+'\', \''+this.data.ditemid+'\', \''+this.data.cutid+'\');"><img style="border: 0;" src="' + Site.imgprefix + '/collapse-end.gif" aria-controls="div-cuttag_' + this.identifier + '" alt="' + expanded + '" title="' + expanded + '"/></a>';
+            replaceDiv.appendChild(closeEnd);
+        }
+
         DOM.addClassName(replaceDiv, "cuttag-open");
         $('img-' + this.identifier).alt=expanded;
         $('img-' + this.identifier).title=expanded;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org