From: Michael M Slusarz Date: Wed, 21 Jan 2009 06:58:51 +0000 (-0700) Subject: Update revlog script. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f66158e16c01c0a71fd9cc4ba02f55b634bf48ec;p=horde.git Update revlog script. --- diff --git a/chora/js/revlog.js b/chora/js/revlog.js index afd80f47c..c8c54b023 100644 --- a/chora/js/revlog.js +++ b/chora/js/revlog.js @@ -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 diff --git a/chora/js/src/revlog.js b/chora/js/src/revlog.js index 20c40ee89..d25ba74d3 100644 --- a/chora/js/src/revlog.js +++ b/chora/js/src/revlog.js @@ -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)); diff --git a/chora/templates/log/rev.inc b/chora/templates/log/rev.inc index 855377f7f..c6b55e973 100644 --- a/chora/templates/log/rev.inc +++ b/chora/templates/log/rev.inc @@ -3,7 +3,7 @@ "> - " onclick="revlog_sdiff(this);"> + " onclick="Chora_RevLog.revlog_sdiff(this);"> abbrev($rev)) . ''; if ($branchName) echo ' ' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . ''; if (!empty($lg->lines)) echo ' (' . sprintf('%s lines', $lg->lines) . ')'; ?>