Update revlog script.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 21 Jan 2009 06:58:51 +0000 (23:58 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 21 Jan 2009 07:06:02 +0000 (00:06 -0700)
chora/js/revlog.js
chora/js/src/revlog.js
chora/templates/log/rev.inc

index afd80f4..c8c54b0 100644 (file)
@@ -1 +1 @@
-var revlog_selected=null;var isMSIE=false;function revlog_highlight(){var a=$("revlog_body");$A(a.getElementsByTagName("TR")).each(function(b){if(isMSIE){Event.observe(b,"mouseover",(function(){Element.addClassName(this,"hover")}).bind(b));Event.observe(b,"mouseout",(function(){Element.removeClassName(this,"hover")}).bind(b))}Event.observe(b,"click",revlog_toggle.bindAsEventListener(b))})}function revlog_toggle(b){var a=Event.element(b);while(a!=this){if(a.tagName.toUpperCase()=="A"&&a.getAttribute("href")){return}a=a.parentNode}if(revlog_selected!=null){Element.removeClassName(revlog_selected,"selected");if(revlog_selected==this){revlog_selected=null;Element.removeClassName("revlog_body","selection");return}}revlog_selected=this;Element.addClassName(this,"selected");Element.addClassName("revlog_body","selection")}function revlog_sdiff(a){a.href=a.href.replace(/r1=([\d\.]+)/,"r1="+revlog_selected.id.substring(3))}Event.observe(window,"load",revlog_highlight);
\ No newline at end of file
+var Chora_RevLog={selected:null,highlight:function(){$("revlog_body").select("TR").each(function(a){if(Prototype.Browser.IE){a.observe("mouseover",this.rowover.bindAsEventListener(this,"over"));a.observe("mouseover",this.rowover.bindAsEventListener(this,"out"))}a.observe("click",this.toggle.bindAsEventListener(this))},this)},rowover:function(b,a){b.element().invoke(a=="over"?"addClassName":"removeClassName","hover")},toggle:function(b){var a=b.element();if(a.tagName.toUpperCase()!="TR"){if(a.tagName.toUpperCase()=="A"&&a.readAttribute("href")){return}a=a.up("TR")}if(this.selected!=null){this.selected.removeClassName("selected");if(this.selected==a){this.selected=null;$("revlog_body").removeClassName("selection");return}}this.selected=a;a.addClassName("selected");$("revlog_body").addClassName("selection")},sdiff:function(a){a=$(a);a.writeAttribute("href",a.readAttribute("href").replace(/r1=([\d\.]+)/,"r1="+this.selected.identify().substring(3)))}};document.observe("dom:loaded",Chora_RevLog.highlight.bind(Chora_RevLog));
\ No newline at end of file
index 20c40ee..d25ba74 100644 (file)
@@ -2,50 +2,57 @@
  * Revision log javascript.
  */
 
-var revlog_selected = null;
-var isMSIE = /*@cc_on!@*/false;
-
-function revlog_highlight()
-{
-    var revlog_body = $('revlog_body');
-
-    $A(revlog_body.getElementsByTagName('TR')).each(function(tr) {
-        if (isMSIE) {
-            Event.observe(tr, 'mouseover', (function() { Element.addClassName(this, 'hover'); }).bind(tr));
-            Event.observe(tr, 'mouseout', (function() { Element.removeClassName(this, 'hover'); }).bind(tr));
-        }
-        Event.observe(tr, 'click', revlog_toggle.bindAsEventListener(tr));
-    });
-}
-
-function revlog_toggle(e)
-{
-    // Ignore clicks on links.
-    var elt = Event.element(e);
-    while (elt != this) {
-        if (elt.tagName.toUpperCase() == 'A' && elt.getAttribute('href')) {
-            return;
+var Chora_RevLog = {
+
+    selected: null,
+
+    highlight: function()
+    {
+        $('revlog_body').select('TR').each(function(tr) {
+            if (Prototype.Browser.IE) {
+                tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'over'));
+                tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'out'));
+            }
+            tr.observe('click', this.toggle.bindAsEventListener(this));
+        }, this);
+    },
+
+    rowover: function(e, type)
+    {
+        e.element().invoke(type == 'over' ? 'addClassName' : 'removeClassName', 'hover');
+    },
+
+    toggle: function(e)
+    {
+        // Ignore clicks on links.
+        var elt = e.element();
+        if (elt.tagName.toUpperCase() != 'TR') {
+            if (elt.tagName.toUpperCase() == 'A' &&
+                elt.readAttribute('href')) {
+                return;
+            }
+            elt = elt.up('TR');
         }
-        elt = elt.parentNode;
-    }
 
-    if (revlog_selected != null) {
-        Element.removeClassName(revlog_selected, 'selected');
-        if (revlog_selected == this) {
-            revlog_selected = null;
-            Element.removeClassName('revlog_body', 'selection');
-            return;
+        if (this.selected != null) {
+            this.selected.removeClassName('selected');
+            if (this.selected == elt) {
+                this.selected = null;
+                $('revlog_body').removeClassName('selection');
+                return;
+            }
         }
-    }
 
-    revlog_selected = this;
-    Element.addClassName(this, 'selected');
-    Element.addClassName('revlog_body', 'selection');
-}
+        this.selected = elt;
+        elt.addClassName('selected');
+        $('revlog_body').addClassName('selection');
+    },
 
-function revlog_sdiff(link)
-{
-    link.href = link.href.replace(/r1=([\d\.]+)/, 'r1=' + revlog_selected.id.substring(3));
-}
+    sdiff: function(link)
+    {
+        link = $(link);
+        link.writeAttribute('href', link.readAttribute('href').replace(/r1=([\d\.]+)/, 'r1=' + this.selected.identify().substring(3)));
+    }
+};
 
-Event.observe(window, 'load', revlog_highlight);
+document.observe('dom:loaded', Chora_RevLog.highlight.bind(Chora_RevLog));
index 855377f..c6b55e9 100644 (file)
@@ -3,7 +3,7 @@
   <?php if ($diffUrl): ?>
   <a href="<?php echo $diffUrl ?>" class="pdiff" title="<?php echo _("Show changes to the previous revision") ?>"><?php echo Horde::img('diff.png') ?></a>
   <?php endif ?>
-  <a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="revlog_sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
+  <a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="Chora_RevLog.revlog_sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
  </td>
  <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
  <td class="ago" sortval="<?php echo (int)$lg->date ?>"><a title="<?php echo $readableDate ?>"><?php echo $commitDate ?></a></td>